# Very simple Ember Data structure from JSON API

**URL:** <https://discuss.emberjs.com/t/very-simple-ember-data-structure-from-json-api/13452>\
**Category:** Ember Data\
**Created:** [August 13, 2017, 11:01am UTC](https://discuss.emberjs.com/t/very-simple-ember-data-structure-from-json-api/13452 "2017-08-13T11:01:44Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![lamamasters](https://avatars.discourse-cdn.com/v4/letter/l/9e8a1a/32.png) [@lamamasters](https://discuss.emberjs.com/u/lamamasters)\
**Post date:** [August 13, 2017, 11:01am UTC](https://discuss.emberjs.com/t/very-simple-ember-data-structure-from-json-api/13452/1 "2017-08-13T11:01:44Z")

</div>

Good God!

I just want to set **MODEL** data **from JSON API** with Ember Data.

Let’s take some base example (list of user names):

**URL:** [https://jsonplaceholder.typicode.com/users](https://jsonplaceholder.typicode.com/users)

My **app/models/user** file:

```auto
export default DS.Model.extend({
    name: DS.attr()
});

```

My **app/adapters/application.js** file:

```auto
export default DS.JSONAPIAdapter.extend({
  host: 'https://jsonplaceholder.typicode.com'
});

```

My **app/router/users.js** file:

```auto
export default Ember.Route.extend({
  model (){
    return this.store.findAll('user');
  }
});

```

My **app/templates/users.hbs** file:

```auto
{{#each model as |user|}}
  <li>{{user.name}}</li>
{{/each}}

```

What should I set to get a list of user names in **MODEL** and my template?

---

<div class="post-metadata">

**Author:** ![broerse](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/broerse/32/9497_2.png) [@broerse](https://discuss.emberjs.com/u/broerse)\
**Post date:** [August 13, 2017, 1:24pm UTC](https://discuss.emberjs.com/t/very-simple-ember-data-structure-from-json-api/13452/2 "2017-08-13T13:24:51Z")

</div>

I just looked at this but as we almost always use [ember-pouch](https://github.com/pouchdb-community/ember-pouch) and not `JSONAPIAdapter` I don’t know how to fix the error.

> Assertion Failed: normalizeResponse must return a valid JSON API document: \* One or more of the following keys must be present: “data”, “errors”, “meta”.

See Twiddle:

> **[Ember Twiddle](https://ember-twiddle.com/#/8bbf99d224037e3913e712c1c0752796?openFiles=adapters.application.js%2C&route=%2Fusers)**
>
> A web-based Ember.js code sharing tool that follows ember-cli's conventions.

---

<div class="post-metadata">

**Author:** ![lamamasters](https://avatars.discourse-cdn.com/v4/letter/l/9e8a1a/32.png) [@lamamasters](https://discuss.emberjs.com/u/lamamasters)\
**Post date:** [August 13, 2017, 1:58pm UTC](https://discuss.emberjs.com/t/very-simple-ember-data-structure-from-json-api/13452/3 "2017-08-13T13:58:27Z")

</div>

Thanks for your answer Broerse!

So the reason why the data can not be retrieved by JSONAPIAdapter is the missing **data** key in the JSON file?

I have to check and understand how the ember-pouch works.

---

<div class="post-metadata">

**Author:** ![broerse](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/broerse/32/9497_2.png) [@broerse](https://discuss.emberjs.com/u/broerse)\
**Post date:** [August 13, 2017, 2:02pm UTC](https://discuss.emberjs.com/t/very-simple-ember-data-structure-from-json-api/13452/4 "2017-08-13T14:02:58Z")

</div>

I have created a jsonapi mock that works for 24 hours. Insert it in the Twiddle and it works `https://demo5604487.mockable.io/`

`Content-Type application/vnd.api+json`

```auto
{
  "data": [{
    "type": "users",
    "id": "1",
    "attributes": {
      "name": "John"
    }
  },{
    "type": "users",
    "id": "2",
    "attributes": {
      "name": "James"
    }      
  }]
}

```

(My pouch example [GitHub - broerse/ember-cli-blog: Tom Dale's blog example updated for the Ember CLI](https://github.com/broerse/ember-cli-blog))

---

<div class="post-metadata">

**Author:** ![broerse](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/broerse/32/9497_2.png) [@broerse](https://discuss.emberjs.com/u/broerse)\
**Post date:** [August 13, 2017, 2:12pm UTC](https://discuss.emberjs.com/t/very-simple-ember-data-structure-from-json-api/13452/5 "2017-08-13T14:12:04Z")

</div>

Updated my twiddle so this works for 24 hours.

> **[Ember Twiddle](https://ember-twiddle.com/#/8bbf99d224037e3913e712c1c0752796?route=%2Fusers)**
>
> A web-based Ember.js code sharing tool that follows ember-cli's conventions.

---

<div class="post-metadata">

**Author:** ![lamamasters](https://avatars.discourse-cdn.com/v4/letter/l/9e8a1a/32.png) [@lamamasters](https://discuss.emberjs.com/u/lamamasters)\
**Post date:** [August 13, 2017, 2:15pm UTC](https://discuss.emberjs.com/t/very-simple-ember-data-structure-from-json-api/13452/6 "2017-08-13T14:15:29Z")

</div>

Thank you for your help! 🙂

---

<div class="post-metadata">

**Author:** ![rustyshackleford](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/rustyshackleford/32/13290_2.png) [@rustyshackleford](https://discuss.emberjs.com/u/rustyshackleford)\
**Post date:** [August 15, 2017, 2:16pm UTC](https://discuss.emberjs.com/t/very-simple-ember-data-structure-from-json-api/13452/7 "2017-08-15T14:16:15Z")

</div>

The API you are trying to call does not follow the [jsonapi.org](http://jsonapi.org) specification.

In order to use ember-data out of the box, you need to use an api that follows the jsonapi specification.

Here are some examples.

[http://jsonapi.org/implementations/#examples](http://jsonapi.org/implementations/#examples)

---

<div class="post-metadata">

**Author:** ![francesconovy](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/francesconovy/32/9607_2.png) [@francesconovy](https://discuss.emberjs.com/u/francesconovy)\
**Post date:** [August 21, 2017, 12:48pm UTC](https://discuss.emberjs.com/t/very-simple-ember-data-structure-from-json-api/13452/8 "2017-08-21T12:48:57Z")

</div>

You can also just start out with the [RESTAdapter](https://emberjs.com/api/ember-data/2.14/classes/DS.RESTAdapter)/RESTSerializer and adapt from there. For example, you could overwrite the [handleResponse](https://emberjs.com/api/ember-data/2.14/classes/DS.RESTAdapter/methods/handleResponse?anchor=handleResponse) method to change the format the API returns into a format the default adapters can work with.

---

<div class="post-metadata">

**Author:** ![sk5202](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@sk5202](https://discuss.emberjs.com/u/sk5202)\
**Post date:** [July 1, 2019, 5:25pm UTC](https://discuss.emberjs.com/t/very-simple-ember-data-structure-from-json-api/13452/9 "2019-07-01T17:25:06Z")

</div>

Hello,

i am facing same issue can you please update your twindle. it exipred

---

<div class="post-metadata">

**Author:** ![dknutsen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dknutsen/32/16471_2.png) [@dknutsen](https://discuss.emberjs.com/u/dknutsen)\
**Post date:** [July 1, 2019, 6:41pm UTC](https://discuss.emberjs.com/t/very-simple-ember-data-structure-from-json-api/13452/10 "2019-07-01T18:41:57Z")

</div>

Hi @sk5202, this is a pretty old thread so you might have better luck just posting a new thread with some more details about what you’re seeing. An example server response and then any details about your adapter/serializer/model would probably be helpful.

---

<div class="post-metadata">

**Author:** ![broerse](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/broerse/32/9497_2.png) [@broerse](https://discuss.emberjs.com/u/broerse)\
**Post date:** [July 1, 2019, 8:06pm UTC](https://discuss.emberjs.com/t/very-simple-ember-data-structure-from-json-api/13452/11 "2019-07-01T20:06:15Z")

</div>

I made a new mock that works for 24 hours. [Ember Twiddle](https://ember-twiddle.com/8bbf99d224037e3913e712c1c0752796?openFiles=adapters.application.js%2C&route=%2Fusers)

We improved [ember-pouch](https://github.com/pouchdb-community/ember-pouch) a lot since this old thread. We even started a free CouchDB hosting you can try with this on [www.cloudstation.com](http://www.cloudstation.com)

---

<div class="post-metadata">

**Author:** ![sk5202](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@sk5202](https://discuss.emberjs.com/u/sk5202)\
**Post date:** [July 2, 2019, 3:55am UTC](https://discuss.emberjs.com/t/very-simple-ember-data-structure-from-json-api/13452/12 "2019-07-02T03:55:25Z")

</div>

Thank you very much it solved my problem.

Problem is JSON adapter have fix format of JSON.

I didn’t pass from you JSON it was clear
