I am trying to get the response data from a REST API URL in my Angular 14 application. But it's not working. How to write a proper POST query?
Details:
getDetails(): Observable<string[]> {
const url = '.../mrkc/prd/api/details';
const headers = new HttpHeaders()
.set('Content-Type', 'application/json')
const body = [{""}];
return this.http.post(url, body, { headers });
}
this.globalService.getDetails().subscribe({
next: data => {
console.log(data);
},
error: error => {
console.error(error);
}
});
All Details:
getAllDetails(): Observable<string[]> {
const url = '.../mrkc/prd/api/allDetails';
const headers = new HttpHeaders()
.set('Content-Type', 'application/json')
const body = [{"labels":{"GroupName":"Power","GroupMembers":{Oil:green}}}];
return this.http.post(url, body, { headers });
}
this.globalService.getAllDetails().subscribe({
next: data => {
console.log(data);
},
error: error => {
console.error(error);
}
});