Angular Component Function
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)
);
}
}
Angular Service Function
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 resolve this error. For example, let photo = this.details.photo;(it works but I want to send it as FormData).