Why is my error in subscirbe (() => {}, err => {here}) different from the error in the browser console

This is a function loadSize(), and it calls a function getTotalNumberCampaigns()in my class campaignsService.

 loadSize() {
    this.campaignsService.getTotalNumberCampaigns().subscribe(value => {//async call
        this.campaignSize = value;
    }, (err: any) => { console.log(err.status); console.log(err);}

    );
}

this is my getTotalNumberCampaigns ()

 getTotalNumberCampaigns(): Observable<number> {
    return this.http.get(`${this.apiUrl}/Count`, { headers: this.headers })
        .map<any>(res => res.json())
}

I run the backend api, everything works fine, now I stop the api and refresh my page. It will run console.log(err.status);console.log (err); because the connection failed. but in fact I have a status of 200, while my browser console says it is a 502 error.

will someone tell me why?

enter image description here

+1
source share
1 answer

, , , , type 3 (ERROR). , , , . "" dev ( "OPTIONS http://localhost:..." )?

. :

0

All Articles