Hi 🙂
I have a backend with NestJS that return me a 405 http code with a custom body.
🛑 405 Method Not Allowed
{
"message": "Event is disabled",
"name": "Error"
}```
When i call it from my Angular app with the HttpClient, i'm not able to get the body if it's an error.
//src/app/services/core/tickets.service.ts
participate(itemId: number, serial: string) {
const ticket = {itemId, serial};
return this.http.post(${this.url}/tickets/participate, ticket, { observe: 'response', responseType: 'json' });
}
//src/app/home/modals/take-chance.component.ts
this.ticketService.participate(this.detail.id, this.ticketForm.value.serial).pipe(
tap(response => {
console.log('Success', response);
this.close();
}),
catchError((error: any) => {
console.log('Error', error);
// const alert = await this.alertController.create({
// header: 'A Short Title Is Best',
// message: 'A message should be a short, complete sentence.',
// buttons: ['Action'],
// });
// await alert.present();
return of(null);
})
).subscribe();
It's probably a stupid thing i miss but if someone can show me the right way to do that 🙂