mardi 3 janvier 2017

Ember normalizeFindAllResponse giving no data from the findAll call

i am trying to use normalizeFindAllResponse in my serializer and the updated payload is not coming through in my call. inside the serializer i can see the data being formatted to what i need but in the actually findAll i am getting no content. i am returning return this._super(store, primaryModelClass, payload, id, requestType); in my RESTSerializer, but other examples i have found say to use return this._super(...arguments);. neither works. btw, don't those both mean the same thing? can someone give me a hand or point me in the right direction?

Adapter:

export default ApplicationAdapter.extend({ urlForFindAll() { return `${hostURL}/admin/permissions`; } });

Serializer:

export default DS.RESTSerializer.extend({ normalizeFindAllResponse (store, primaryModelClass, payload, id, requestType) { let permissionsArray = Ember.A(); permissionsArray = payload.permissions.map((element, index)=>{ return Ember.Object.create({ id: index + 1, permission: element }); }); return this._super(store, primaryModelClass, permissionsArray, id, requestType); } });

Route:

export default Ember.Route.extend({ model() { return this.store.findAll('permission').then((perms) => { if (perms.content.length === 0) { this.transitionTo('shop'); } }); } });




Aucun commentaire:

Enregistrer un commentaire