# Ionic v4 : HttpErrorResponse!

**URL:** <https://forum.ionicframework.com/t/ionic-v4-httperrorresponse/156802>\
**Category:** Ionic Framework\
**Created:** [February 19, 2019, 12:34pm UTC](https://forum.ionicframework.com/t/ionic-v4-httperrorresponse/156802 "2019-02-19T12:34:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![youssefelgarny](https://avatars.discourse-cdn.com/v4/letter/y/71c47a/32.png) [@youssefelgarny](https://forum.ionicframework.com/u/youssefelgarny)\
**Post date:** [February 19, 2019, 12:34pm UTC](https://forum.ionicframework.com/t/ionic-v4-httperrorresponse/156802/1 "2019-02-19T12:34:28Z")

</div>

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

 ![image](https://global.discourse-cdn.com/ionicframework/original/3X/9/d/9d70b93d28a5eba18a0c432b8d2bdbd5e106daba.png)

> service.ts

```auto
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);
        }));
    
  }

}

```

---

<div class="post-metadata">

**Author:** ![patrick-ulster](https://avatars.discourse-cdn.com/v4/letter/p/6de8d8/32.png) [@patrick-ulster](https://forum.ionicframework.com/u/patrick-ulster)\
**Post date:** [February 19, 2019, 12:36pm UTC](https://forum.ionicframework.com/t/ionic-v4-httperrorresponse/156802/2 "2019-02-19T12:36:17Z")

</div>

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

```auto
'Content-Type application/json'

```

---

<div class="post-metadata">

**Author:** ![youssefelgarny](https://avatars.discourse-cdn.com/v4/letter/y/71c47a/32.png) [@youssefelgarny](https://forum.ionicframework.com/u/youssefelgarny)\
**Post date:** [February 19, 2019, 12:49pm UTC](https://forum.ionicframework.com/t/ionic-v4-httperrorresponse/156802/3 "2019-02-19T12:49:33Z")

</div>

@patrick-ulster that what the API returning

 ![image](https://global.discourse-cdn.com/ionicframework/original/3X/0/0/0074ff33ec68581e48801c7299f465c4ce5f7890.png)

---

<div class="post-metadata">

**Author:** ![patrick-ulster](https://avatars.discourse-cdn.com/v4/letter/p/6de8d8/32.png) [@patrick-ulster](https://forum.ionicframework.com/u/patrick-ulster)\
**Post date:** [February 19, 2019, 1:01pm UTC](https://forum.ionicframework.com/t/ionic-v4-httperrorresponse/156802/4 "2019-02-19T13:01:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![youssefelgarny](https://avatars.discourse-cdn.com/v4/letter/y/71c47a/32.png) [@youssefelgarny](https://forum.ionicframework.com/u/youssefelgarny)\
**Post date:** [February 19, 2019, 1:04pm UTC](https://forum.ionicframework.com/t/ionic-v4-httperrorresponse/156802/5 "2019-02-19T13:04:45Z")

</div>

![image](https://global.discourse-cdn.com/ionicframework/original/3X/9/5/954027226a0f25f04cf7edd8d9c07deb6492860b.png)

---

<div class="post-metadata">

**Author:** ![patrick-ulster](https://avatars.discourse-cdn.com/v4/letter/p/6de8d8/32.png) [@patrick-ulster](https://forum.ionicframework.com/u/patrick-ulster)\
**Post date:** [February 19, 2019, 2:57pm UTC](https://forum.ionicframework.com/t/ionic-v4-httperrorresponse/156802/6 "2019-02-19T14:57:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![youssefelgarny](https://avatars.discourse-cdn.com/v4/letter/y/71c47a/32.png) [@youssefelgarny](https://forum.ionicframework.com/u/youssefelgarny)\
**Post date:** [February 19, 2019, 5:05pm UTC](https://forum.ionicframework.com/t/ionic-v4-httperrorresponse/156802/7 "2019-02-19T17:05:25Z")

</div>

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.
