Return this message: “Uncaught TypeError: Cannot read property ‘replace’ of undefined”
What is the correct way to transform a json object to an internal model?. I need this record to be automatically added to a #each that I have in the template.
What does the model() function look like in the application route? The use of model.notifications looks suspicious to me in the use case you described.
Sorry for the diversion. What you had for model.notifications is correct. However, there may be an issue with the how you are handling the promise to the RSVP.hash(). What behavior do you get if you omit the .then() ?
The response that is passed when the RSVP.hash resolves will have the same shape as the hash passed in the .hash() method. It should look like
{
notifications : …
totalNotifications : …
}
I use RSVP.hash() all over the place, and I have to admit that the fact that the code on line 24 is working at has me scratching my head.
Also, if you want a createRecord() to appear in a template along with a list of records fetched in a model() hook, you need to use one of the DS.Store methods that returns a RecordArray. .query() returns a slightly different animal when resolved, and templates are synced with changes.
Hi, try to convert your notifications to array with toArray() method before returning them from model hook:
this.get('store').query('notification', {"user": user_id, "limit": 10}).then(notifications => notifications.toArray())