Argument of type 'void' is not assignable to parameter of type 'string' in Angular 6
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Mycomponent
onFileChangedForCV(event) {
this.details.= event.target.files[0]
}
candidateDetails(){
let formData = new FormData();
let photo= formData.append('profile_pic',this.details.photo);
let name=this.details.name;
let age = this.details.age;
let cv = this.details.cv;
let experience = this.details.experience;
let current_salary = this.details.current_salary;
let expected_salary = this.details.expected_salary;
let notice_period = this.details.notice_period;
if (this.contentEditable){
this.detaisservice.candidateDetailsExperienced(photo(Here throwing ERROR),name,age,cv,experience,current_salary,expected_salary,notice_period)
.subscribe(
data => {
this.details.DetailsResponse = data;
if(this.details.DetailsResponse.code =='200'){
}
},
error => alert(error),
() => console.log(this.details.DetailsResponse)
);
}
}
MyService File
candidateDetailsFresher(photo:string,name:string,age:string,cv:string){
let body = JSON.stringify({photo:photo,name:name,age:age,cv:cv});
let headers = new Headers({ 'Content-Type': 'application/json'});
let options = new RequestOptions({ headers: headers });
console.log(body);
console.log(options);
return this.http.post('http://127.0.0.1:8000/api/seeker/candidate_details/', body, options)
.map(this.extractData)
.catch(this.handleError);
}
private extractData(res: Response) {
let body = res.json();
return body || ;
}
private handleError (error: any) {
return Observable.throw(error.json().error || 'Server error');
}
Error:Argument of type 'void' is not assignable to parameter of type 'string'. It's showing error when i am trying to call API in Angular 6 .Please help me to resolve this error.Ex:let photo = this.details.photo; (it working but i want to Send as FormData).
angular typescript
add a comment |
Mycomponent
onFileChangedForCV(event) {
this.details.= event.target.files[0]
}
candidateDetails(){
let formData = new FormData();
let photo= formData.append('profile_pic',this.details.photo);
let name=this.details.name;
let age = this.details.age;
let cv = this.details.cv;
let experience = this.details.experience;
let current_salary = this.details.current_salary;
let expected_salary = this.details.expected_salary;
let notice_period = this.details.notice_period;
if (this.contentEditable){
this.detaisservice.candidateDetailsExperienced(photo(Here throwing ERROR),name,age,cv,experience,current_salary,expected_salary,notice_period)
.subscribe(
data => {
this.details.DetailsResponse = data;
if(this.details.DetailsResponse.code =='200'){
}
},
error => alert(error),
() => console.log(this.details.DetailsResponse)
);
}
}
MyService File
candidateDetailsFresher(photo:string,name:string,age:string,cv:string){
let body = JSON.stringify({photo:photo,name:name,age:age,cv:cv});
let headers = new Headers({ 'Content-Type': 'application/json'});
let options = new RequestOptions({ headers: headers });
console.log(body);
console.log(options);
return this.http.post('http://127.0.0.1:8000/api/seeker/candidate_details/', body, options)
.map(this.extractData)
.catch(this.handleError);
}
private extractData(res: Response) {
let body = res.json();
return body || ;
}
private handleError (error: any) {
return Observable.throw(error.json().error || 'Server error');
}
Error:Argument of type 'void' is not assignable to parameter of type 'string'. It's showing error when i am trying to call API in Angular 6 .Please help me to resolve this error.Ex:let photo = this.details.photo; (it working but i want to Send as FormData).
angular typescript
add a comment |
Mycomponent
onFileChangedForCV(event) {
this.details.= event.target.files[0]
}
candidateDetails(){
let formData = new FormData();
let photo= formData.append('profile_pic',this.details.photo);
let name=this.details.name;
let age = this.details.age;
let cv = this.details.cv;
let experience = this.details.experience;
let current_salary = this.details.current_salary;
let expected_salary = this.details.expected_salary;
let notice_period = this.details.notice_period;
if (this.contentEditable){
this.detaisservice.candidateDetailsExperienced(photo(Here throwing ERROR),name,age,cv,experience,current_salary,expected_salary,notice_period)
.subscribe(
data => {
this.details.DetailsResponse = data;
if(this.details.DetailsResponse.code =='200'){
}
},
error => alert(error),
() => console.log(this.details.DetailsResponse)
);
}
}
MyService File
candidateDetailsFresher(photo:string,name:string,age:string,cv:string){
let body = JSON.stringify({photo:photo,name:name,age:age,cv:cv});
let headers = new Headers({ 'Content-Type': 'application/json'});
let options = new RequestOptions({ headers: headers });
console.log(body);
console.log(options);
return this.http.post('http://127.0.0.1:8000/api/seeker/candidate_details/', body, options)
.map(this.extractData)
.catch(this.handleError);
}
private extractData(res: Response) {
let body = res.json();
return body || ;
}
private handleError (error: any) {
return Observable.throw(error.json().error || 'Server error');
}
Error:Argument of type 'void' is not assignable to parameter of type 'string'. It's showing error when i am trying to call API in Angular 6 .Please help me to resolve this error.Ex:let photo = this.details.photo; (it working but i want to Send as FormData).
angular typescript
Mycomponent
onFileChangedForCV(event) {
this.details.= event.target.files[0]
}
candidateDetails(){
let formData = new FormData();
let photo= formData.append('profile_pic',this.details.photo);
let name=this.details.name;
let age = this.details.age;
let cv = this.details.cv;
let experience = this.details.experience;
let current_salary = this.details.current_salary;
let expected_salary = this.details.expected_salary;
let notice_period = this.details.notice_period;
if (this.contentEditable){
this.detaisservice.candidateDetailsExperienced(photo(Here throwing ERROR),name,age,cv,experience,current_salary,expected_salary,notice_period)
.subscribe(
data => {
this.details.DetailsResponse = data;
if(this.details.DetailsResponse.code =='200'){
}
},
error => alert(error),
() => console.log(this.details.DetailsResponse)
);
}
}
MyService File
candidateDetailsFresher(photo:string,name:string,age:string,cv:string){
let body = JSON.stringify({photo:photo,name:name,age:age,cv:cv});
let headers = new Headers({ 'Content-Type': 'application/json'});
let options = new RequestOptions({ headers: headers });
console.log(body);
console.log(options);
return this.http.post('http://127.0.0.1:8000/api/seeker/candidate_details/', body, options)
.map(this.extractData)
.catch(this.handleError);
}
private extractData(res: Response) {
let body = res.json();
return body || ;
}
private handleError (error: any) {
return Observable.throw(error.json().error || 'Server error');
}
Error:Argument of type 'void' is not assignable to parameter of type 'string'. It's showing error when i am trying to call API in Angular 6 .Please help me to resolve this error.Ex:let photo = this.details.photo; (it working but i want to Send as FormData).
angular typescript
angular typescript
edited Nov 16 '18 at 12:26
lpd
asked Nov 16 '18 at 12:05
lpdlpd
4218
4218
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The issue with
let photo= formData.append('profile_pic',this.details.photo);
append
function of FormData returns void
so basically your variable photo
is void here and you are trying to pass the void
value to candidateDetailsExperienced
however it is expecting it to be string
.
So change your photo variable of type string
. I guess you can use this.details.photo
instead.
You can break this line
let photo= formData.append('profile_pic',this.details.photo);
to
formData.append('profile_pic',this.details.photo);
let photo = this.details.photo; //<-- you can change to other string value if reuqired.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337569%2fargument-of-type-void-is-not-assignable-to-parameter-of-type-string-in-angul%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The issue with
let photo= formData.append('profile_pic',this.details.photo);
append
function of FormData returns void
so basically your variable photo
is void here and you are trying to pass the void
value to candidateDetailsExperienced
however it is expecting it to be string
.
So change your photo variable of type string
. I guess you can use this.details.photo
instead.
You can break this line
let photo= formData.append('profile_pic',this.details.photo);
to
formData.append('profile_pic',this.details.photo);
let photo = this.details.photo; //<-- you can change to other string value if reuqired.
add a comment |
The issue with
let photo= formData.append('profile_pic',this.details.photo);
append
function of FormData returns void
so basically your variable photo
is void here and you are trying to pass the void
value to candidateDetailsExperienced
however it is expecting it to be string
.
So change your photo variable of type string
. I guess you can use this.details.photo
instead.
You can break this line
let photo= formData.append('profile_pic',this.details.photo);
to
formData.append('profile_pic',this.details.photo);
let photo = this.details.photo; //<-- you can change to other string value if reuqired.
add a comment |
The issue with
let photo= formData.append('profile_pic',this.details.photo);
append
function of FormData returns void
so basically your variable photo
is void here and you are trying to pass the void
value to candidateDetailsExperienced
however it is expecting it to be string
.
So change your photo variable of type string
. I guess you can use this.details.photo
instead.
You can break this line
let photo= formData.append('profile_pic',this.details.photo);
to
formData.append('profile_pic',this.details.photo);
let photo = this.details.photo; //<-- you can change to other string value if reuqired.
The issue with
let photo= formData.append('profile_pic',this.details.photo);
append
function of FormData returns void
so basically your variable photo
is void here and you are trying to pass the void
value to candidateDetailsExperienced
however it is expecting it to be string
.
So change your photo variable of type string
. I guess you can use this.details.photo
instead.
You can break this line
let photo= formData.append('profile_pic',this.details.photo);
to
formData.append('profile_pic',this.details.photo);
let photo = this.details.photo; //<-- you can change to other string value if reuqired.
answered Nov 16 '18 at 12:18
Sunil SinghSunil Singh
6,4772628
6,4772628
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337569%2fargument-of-type-void-is-not-assignable-to-parameter-of-type-string-in-angul%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown