# TypeError: res.json is not a function

**URL:** <https://forum.ionicframework.com/t/typeerror-res-json-is-not-a-function/119458>\
**Category:** ionic-v3\
**Created:** [January 25, 2018, 10:51pm UTC](https://forum.ionicframework.com/t/typeerror-res-json-is-not-a-function/119458 "2018-01-25T22:51:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![barreola](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/barreola/32/116725_2.png) [@barreola](https://forum.ionicframework.com/u/barreola)\
**Post date:** [January 25, 2018, 10:51pm UTC](https://forum.ionicframework.com/t/typeerror-res-json-is-not-a-function/119458/1 "2018-01-25T22:51:10Z")

</div>

Why is not a function? I’ve read [this](https://stackoverflow.com/questions/46630893/angular-res-json-is-not-a-function) but I cannot make it work for my project, the error is shown in the following code

````auto
getListVideos(listId) {
    return this.http.get('https://www.googleapis.com/youtube/v3/playlistItems?key=' + this.apiKey + '&playlistId=' + listId +'&part=snippet,id&maxResults=20')
    .map((res: Response) => {
      return res.json()['items'];
    })
  }```
````

---

<div class="post-metadata">

**Author:** ![alsvader](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/alsvader/32/110297_2.png) [@alsvader](https://forum.ionicframework.com/u/alsvader)\
**Post date:** [January 26, 2018, 5:14am UTC](https://forum.ionicframework.com/t/typeerror-res-json-is-not-a-function/119458/2 "2018-01-26T05:14:59Z")

</div>

Are you using HttpClient or Http module?

---

<div class="post-metadata">

**Author:** ![barreola](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/barreola/32/116725_2.png) [@barreola](https://forum.ionicframework.com/u/barreola)\
**Post date:** [January 26, 2018, 7:56pm UTC](https://forum.ionicframework.com/t/typeerror-res-json-is-not-a-function/119458/3 "2018-01-26T19:56:55Z")

</div>

`import { HttpClient } from '@angular/common/http';` and variable in constructor `public http: HttpClient`

---

<div class="post-metadata">

**Author:** ![AaronSterling](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@AaronSterling](https://forum.ionicframework.com/u/AaronSterling)\
**Post date:** [January 26, 2018, 8:08pm UTC](https://forum.ionicframework.com/t/typeerror-res-json-is-not-a-function/119458/4 "2018-01-26T20:08:22Z")

</div>

HttpClient automatically imports json. Let’s say you are expecting to read an object of type User.

`return this.http.get<User>(url).subscribe(user => console.log(user));`  
The variable user is of type User.

Without specifying a type, your response is automatically json. No need to parse it to json.

[https://angular.io/guide/http#making-a-request-for-json-data](https://angular.io/guide/http#making-a-request-for-json-data)

---

<div class="post-metadata">

**Author:** ![theyashitiwari](https://avatars.discourse-cdn.com/v4/letter/t/59ef9b/32.png) [@theyashitiwari](https://forum.ionicframework.com/u/theyashitiwari)\
**Post date:** [July 21, 2018, 2:38pm UTC](https://forum.ionicframework.com/t/typeerror-res-json-is-not-a-function/119458/5 "2018-07-21T14:38:09Z")

</div>

good answer, it solved my problem in once. i just remove json from res.json and my other problems also got removed.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:53pm UTC](https://forum.ionicframework.com/t/typeerror-res-json-is-not-a-function/119458/6 "2021-07-19T21:53:10Z")

</div>


