HttpClient return Html instead of Json


#1

Hi guys I’m having this issue. I’m expecting a Json but instead I recivied an Html. On Postman work fine.

So I get this error.


#2

I was expecting text but instead I received a bunch of images.


#3
  getPosData():Observable<any>{
    
    let url = this.isProd ? this.urlBaseProd : this.urlBase;
    url += "pos/getposall";   
    
    return this.httpClient.get(url);
    

  }

#4

Instead of abusing any, define a business object interface:

interface Pos {
  stuff: string;
  moreStuff: string;
  noIdeaWhatGoesInHere: number;
}

Then, all you have to do is:

this.httpClient.get<Pos>(url);

HttpClient will automatically give you an Observable<Pos>.


#5

Hi,
You have a problem in your backend. The backend responds with code 200, but should throw a 500 error.


#6

yes, It was a problem on my backend and frontend both was working on same port, so I changed my backend port and now works fine.