Getting this error . Not sure why i am getting this error....would appreciate if someone can help me spot why this is erroring out.
Error while loading route: Error: Assertion Failed: You must include an id in a hash passed to push at new Error (native) at Error.Ember.Error
from the other posts related to similar error this has to do with a json where primary key is not handled correctly. But my json response looks correct.
****here are model objects:****
var PersonInfo = DS.Model.extend({
first: DS.attr('string'),
last : DS.attr('string'),
addresses: DS.hasMany('personAddress', {embedded: 'always'})
});
Ember.Inflector.inflector.irregular("personInfo", "peopleInfo");
export default PersonInfo;
var Address = DS.Model.extend({
type: DS.attr('string'),
personInfo: DS.belongsTo('personInfo')
});
export default Address;
****here is my deserializer:****
var PersonInfoSerializer = DS.ActiveModelSerializer.extend({
primaryKey: 'id',
extractArray: function(store, type, payload, id, requestType) {
var peopleInfo =payload.peopleInfo;
var adds = [];
// debugger;
peopleInfo.forEach(function(personInfo){
var addresses = personInfo.addresses,
addressIds = addresses.mapProperty('id');
adds.push(addresses);
personInfo.addresses = addressIds;
});
payload.addresses = adds;
return this._super(store, type, payload, id, requestType); }
});
export default PersonInfoSerializer;
****and here is the json response which i am mocking in API STUB****
server.get('/peopleInfo', function(req, res) {
var person_info = {
"peopleInfo": [{
"id": "1",
"first": "Tom",
"last": "Dale",
"addresses": [{
"id": "1",
"type": "Home"
}, {
"id": "2",
"type": "Work"
}]
}]
};
res.send(person_info);
});