kindly help I am trying to get Json data from HTTP link
<span class="subjectSpan">{{ title }}</span>
and the .ts file conatins
constructor(public dialog: MatDialog, private api:ServiceUserService) {};
title:any;
ngOnInit() {
this.title = this.api.apiCall().subscribe(data => {
this.title = data;
})
}
and the .service.ts file has
apiCall() {
return this.httpClient.get('https://jsonplaceholder.typicode.com/todos/1');
}
I have imported HTTPCLIENTMODULE in module.ts and .ts file
Just the data from json is not showing just
[object object] is coming as result.
the json file contains
{"status":"success","results":2,"data":{"subject":[{"subject":"ART & HUMANITIES","numTitles":1,"slug":"art-humanities"},{"subject":"ANTHROPOLOGY","numTitles":1,"slug":"anthropology"}]}}
or getting this error
Element implicitly has an 'any' type because expression of type '"title"' can't be used to index type 'Object'.
Property 'title' does not exist on type 'Object'.
this.title = ..."