I'm 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 use the JSON API spec v1.0, this is an example of an array of resources obtained using GET / articles
{
"links" : {
"self" : "http://localhost:8080/test-app/rest/articles"
},
"data" : [
{
"id" : "5666157634499515eb7e13f0",
"type" : "articles",
"attributes" : {
"title" : "test"
}
},
{
"id" : "5666157634499515eb7e13f1",
"type" : "articles",
"attributes" : {
"title" : "test2"
}
},
...
]
}
and my article route is as follows:
// routes/articles.js
...
export default Ember.Route.extend({
model() {
return this.store.findAll('article');
}
});
and 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 closely ( https://guides.emberjs.com/v2.2.0/tutorial/ember-data/ ). But 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 data is not displayed. I see that the data is being requested and returned correctly, but they are somehow interpreted.
My question is: what's wrong? I tried to stick with the default API to not write any adapters or serializers, but it does not work.
-
UPDATE: "" , :
WARNING: Encountered "links" in payload, but no model was found for model name "link" (resolved model name using test-app@serializer:-rest:.modelNameFromPayloadKey("links"))
WARNING: Encountered "data" in payload, but no model was found for model name "datum" (resolved model name using test-app@serializer:-rest:.modelNameFromPayloadKey("data"))
-
2: , , API, :
{
"articles" : [ {
"id" : "5666157634499515eb7e13f0",
"attributes" : {
"title" : "test"
}
}, {
"id" : "5666141034499511aea5f43c",
"attributes" : {
"title" : "test"
}
},
...
}
: ember
, , ember - . ember 2.2.0, . ember cli, ember 1.13 2.2.0.
-
3: . . ( ). , REST. ember-cli , RESTAdapter, JSONAPIAdapter.