I want to get data from https://trackapi.nutritionix.com/v2/natural/nutrients for my calorie calculator . it needs x-app-id and x-app-key for authentication.
What i have tried : (Service.ts)
fetchFood(){
let url = 'https://trackapi.nutritionix.com/v2/natural/nutrients';
let headers = new HttpHeaders({
'Content-Type': 'application/json',
'x-app-id': 'aea728dc',
'x-app-key': 'b945aeaf7ce6a860870f8686248a9485',
});
let query="banana"
let options = { headers: headers };
return this.http.post<any>(url, {query}, options).pipe(
map((res) => {
console.log(res);
})
);
}
register.component.ts
this.authService.fetchFood();
it Shows nothing when i console response. is there any problem in api call??
Thanks!!