I am trying to send http post request from my createorder.component.ts page to create a record. But I am getting HttpErrorResponse error. Where I am doing wrong? please help
createorder.component.ts
onSubmit(form: any) {
this.spinner.show();
this.http.post('/api/order/' + '_foodforest' + '/' + '9ed7f9d5-8ed3-4f57-b360-7e4da87f2d6d' ,
JSON.stringify(form.value))
.subscribe(result => {
this.spinner.hide();
});
}
Error

Angular HttpClient try to parse the api response into JSON by default.
Your API response is not in a JSON format and JSON.parse is failed inside HttpClient.
You can return the api response as JSON from backend or should tell the http client that the type of resposne is not a JSON:
this.http.post(url, JSON.stringify(form.value), {
responseType: 'text'
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With