I try to make a list from REST api datas.
The server give me a response like this:
{
"data" : [
{
"playId" : "624a6a21-d2b4-40c4-a241-0d9660a17676",
"title" : "Hamlet",
"seats" : 250,
"reservableSeats" : 200,
"location" : "The Dysk",
"time" : "2017-08-02T22:10:00.000+01:00",
"readOnly" : false,
"isCanceled" : false
{
"playId" : "624a6a21-d2b4-40c4-a241-0d9660a17677",
"title" : "Hamlet2",
"seats" : 250,
"reservableSeats" : 180,
"location" : "The Dysk",
"time" : "2017-08-03T22:10:00.000+01:00",
"readOnly" : false,
"isCanceled" : false
}
],
"prevPage" : "http://ift.tt/2mZVF0N",
"nextPage" : "http://ift.tt/2ndCxih",
"objectCount" : 2
}
I have an adapter: app/adapters/application.js
import Ember from 'ember';
import DS from 'ember-data';
import JSONAPIAdapter from 'ember-data/adapters/json-api';
export default DS.JSONAPIAdapter.extend({
namespace: 'admin/v1',
host: `http://ift.tt/2n05KLk`,
authManager: Ember.inject.service(),
headers: Ember.computed('authManager.accessToken', function() {
return {
"X-Auth-Token": `${this.get("authManager.accessToken")}`
};
})
});
I want to use this model: app/models/demoplays.js
import DS from 'ember-data';
export default DS.Model.extend({
playId: DS.attr('string'),
title: DS.attr('string'),
seats: DS.attr('number'),
reservableSeats: DS.attr('number'),
location: DS.attr('string'),
time: DS.attr('date'),
readOnly: DS.attr('boolean'),
isCanceled: DS.attr('boolean')
});
I tried few serializers like RESTSerializer in app/serializers/application.js or app/serializers/demoplay.js but my models still empty.
After XHR finished loading i get two warning like this: WARNING: Encountered "objectCount" in payload, but no model was found for model name "object-count" (resolved model name using sorszamgep@serializer:demoplays:.modelNameFromPayloadKey("objectCount")).
Why my models empty?
Aucun commentaire:
Enregistrer un commentaire