I am currently trying to create a simple Ember Application with Ember version 2.2.0 and Ember Data 2.2.1. I created my REST API to follow JSON API spec v1.0, this is an example of a resource array retrieved with GET /articles
{
"data" : [
{
"id" : "5666157634499515eb7e13f0",
"type" : "articles",
"attributes" : {
"title" : "test"
}
},
{
"id" : "5666157634499515eb7e13f1",
"type" : "articles",
"attributes" : {
"title" : "test2"
}
},
...
]
}
and my articles route looks like this:
// routes/articles.js
...
export default Ember.Route.extend({
model() {
return this.store.findAll('article');
}
});
and the model:
// models/article.js
...
export default DS.Model.extend({
title: DS.attr(),
text: DS.attr(),
url: DS.attr(),
date: DS.attr()
});
I followed the tutorial (http://ift.tt/1O9iPwG) exactly. Yet when I open the view, I get a warning:
WARNING: Encountered "data" in payload, but no model was found for model name "datum" (resolved model name using test-app@serializer:-rest:.modelNameFromPayloadKey("data"))
and no data is rendered. I can see the data being requested and returned correctly, but it is interpreted in the wrong way somehow.
My question is: what is wrong? I tried to stick to the default API to not write any adapters or serializers, but it is not working.
Aucun commentaire:
Enregistrer un commentaire