I've got a model called "Membership" that has a string attribute "inviteToken" which I would like to use as my primary key.
I've created the following serializer, but cannot get it to pick up the primary key from the JSON.
app/serializers/membership.js:
import DS from 'ember-data';
export default DS.JSONAPISerializer.extend({
primaryKey: 'invite-token' // also tried 'inviteToken'
});
The specific error I'm getting is:
Error while processing route: invitations.show Assertion Failed: You must include an 'id' for membership in an object passed to 'push'
Error: Assertion Failed: You must include an 'id' for membership in an object passed to 'push'
API Response:
{
"jsonapi":{
"version":"1.0"
},
"data":{
"type":"membership",
"id":"30",
"attributes":{
"invite-token":"5bGo7IhZh93E4SB07VWauw"
}
}
}
The strange thing is that if I use "type" as the primary key, I see "membership" as the id in the ember inspector. It's as if ember data doesn't know how to use something from the "attributes". I'm using ember data 2.4.0.
Aucun commentaire:
Enregistrer un commentaire