I'm attempting to subscribe to my interface and monitor for any changes, but I keep encountering errors.
Fetching data from the API and assigning it to this.candidateProfile :
export interface CandidateProfile { about: string, c_id: {}, certificates_training: [], city: string, country: string, currency: string, email: string, expectedpayhourly: boolean, expectedpayhourlyend: number, expectedpayhourlystart: number, expectedpaymonthly: {}, expectedpaymonthlyend: number, expectedpaymonthlystart: number, experience: [], firstname: string, hobbies: {}, jobskills: [], langugaes: {}, lastname: string, personalskills: [], photo: string, remotework: boolean, role: string, studies: {}, willingtorelocate: {}, willingtorelocatecity: {}, worktype: string }
Auth.service.ts :
candidateProfile: Observable<CandidateProfile>;
getProfile(id, token) {
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
})
};
this.http.get(`users/${id}`, httpOptions).subscribe(data => {
this.candidateProfile = data;
},
(error) => { console.log(error) },
() => {
console.log('received profile', this.candidateProfile);
})
}
Component.ts :
this.auth.candidateProfile.subscribe( data => {
console.log(data)
})
Error message :