I have some data coming in from a web api, but the data is not binding to the view for some reason, I have a service for the api call and then I am injecting that into the component.ts file and into the html, so far I have:
The web api structure(rest) result in console
result: Array(1)
0:
active: "true"
activity_due: ""
additional_assignee_list: ""
approval: "not requested"
approval_history: "
etc etc
service.ts
getIncident(s_id, cId): Observable<any> {
return this.http.get<any>(this.incidentApiUrl + "/" + s_id + "?customer_id=" + cId)
.pipe(
catchError(this.handleError)
);
}
componet.ts:
constructor(private service: nowService,
private appComponent: AppComponent,
private userService: UserService,
private router: Router,
private http: HttpClient,
private route: ActivatedRoute
) {
this.receivedUser = { firstname: '', email: '', lastname: '', name: '' }
this.receivedIncident = { number: '', opened_at: '', description: '', short_description: ''}; this.receivedLocation = {city:null, country: null}
}
private getIncident() {
this.service.getIncident(this.s_id, this.customer_id).subscribe((data) => {
this.loading = true;
console.log('Result - ', data);
console.log('incident data is received');
this.loading = true;
this.receivedIncident = data.result;
//this.service.getLocationsCustomer(this.receivedIncident.location.value).subscribe(location => {
if (this.receivedIncident.location) {
this.service.getLocations(this.receivedIncident.location.value).subscribe(location => {
console.log('location --', location)
this.loading = false;
this.receivedLocation = location.result;
});
} else {
this.loading = false;
}
})
}
html.binding.
<h2 class="text-secondary">Incident #{{receivedIncident.number}}</h2>
Might be something to do with the data structure in the web api?? any ideas?