DEV Community

Lalarukh khan
Lalarukh khan

Posted on

HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: 'Unknown Error', url: 'my_url', ok: false, …}

Hey there,
I'm trying to get response from POST_API. But I can't get that inside my component.ts
Here's my code:

roomtypes: any;
  errorMessage: String = "";
  ngOnInit(): void {
    this.http.post<any>('https://backend.revroo.io/api/v1/booking-engine/get-hotels', { title: 'Angular POST Request Example' }).subscribe({
        next: roomtype => {
            this.roomtypes = roomtype.id;
        },
        error: error => {
            this.errorMessage = error.message;
            console.error('There was an error!', error);
        }
    })
  }
Enter fullscreen mode Exit fullscreen mode

Image description
Seeking Help!

Top comments (0)