Ionic v4 : HttpErrorResponse!

hello,
please i need your help … i am trying to get data from REST API and i get that error !

i am using ionic v4

service.ts

import { Injectable } from '@angular/core';
import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';


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

  

  constructor(private http: HttpClient) {
  }

  // service that test if the user exist or not
  authentification(user:string,password:string):Observable<any>{

   

    const headers = new HttpHeaders({
      'Content-Type': 'application/json',
      'JsonStub-User-Key': '732e939b-05b7-4877-8d8f-f924e67638eb',
      'JsonStub-Project-Key': '31ec72a8-2779-4931-843f-1cbd37b81b2c',
      "Access-Control-Allow-Headers" : "*"
    });
    return this.http.get('http://jsonstub.com/enova_sante_app/api/services/patient',{headers,responseType: 'json'})
        .pipe(map(data => {

          //console.log(data.status);
          console.log(data); // data received by server
          //console.log(data.headers);
          return data;
          
        },
        (error: any) => {
            console.log(error);
        }));
    
  }


}

Looks like the API is not returning JSON. Make sure the API has the following header,

'Content-Type application/json'
1 Like

@patrick-ulster that what the API returning

Click on the Raw tab and show me what is being returned.

1 Like

In chrome can you go to the network tab and show me the response from the API?

1 Like

thank you so much for your time
now it’s working with me after i restart my computer and i open it in a private chrome window.