Unhandled Promise Rejection: Error: Error response received for message...

Discussão em 'Angular' iniciado por Yardi, Dezembro 26, 2024.

  1. Yardi

    Yardi Guest

    I have first time in my life error from my title: Unhandled Promise Rejection: Error: Error response received for message . I don't have any idea what making that error, but fortunately I have only one api call currently in my app. I headed I should add some catch or promise.all, but I don't know where and every attempt fails. There is my code:

    component.ts:

    async ngOnInit(): Promise<void> {
    await this.attractionService.getAttractions().then((results) => {
    results.forEach((attraction: { id: number; name: string; description: string; type: string; distance: string | undefined; imagePath: string | undefined; }) => {
    this.section2ndModelAttractions.push(
    new Card(
    attraction.id,
    attraction.name,
    attraction.description,
    attraction.type,
    attraction.distance,
    attraction.imagePath
    )
    )
    })
    })
    }


    And my attraction service:

    import { HttpClient } from '@angular/common/http';
    import { Injectable } from '@angular/core';
    import { firstValueFrom } from 'rxjs';

    @Injectable({
    providedIn: 'root'
    })
    export class AttractionService {

    constructor(private http: HttpClient) { }

    async getAttractions(): Promise<any> {
    return firstValueFrom(this.http.get<any>("https://localhost:7273/api/Attraction/All"));
    }
    }


    Somebody can tell me what I should do with my code to fix that error? Or maybe you guys need more details to fix it, I will provide what you need to fix that.

    #Edit 1

    I commented all code above and remove async on ngOnInit and I still have this error. I also posted whole error in edit below. I don't know what causes that error. How to get to the source of it?

    Error:

    Unhandled Promise Rejection: Error: Error response received for message <get-frame-manager-configuration>
    PromiseEmptyOnRejected
    PromiseReactionJob


    #Edit 2

    I found something important! Error only appears in safari browser on macOS.

    Continue reading...

Compartilhe esta Página