please help me i am in trouble with the following error in my ember application
Error while processing route: index Assertion Failed: You must include an ‘id’ for tasks in an object passed to ‘push’ Error: Assertion Failed: You must include an ‘id’ for tasks in an object passed to ‘push’
Uncaught (in promise) Error: Assertion Failed: You must include an ‘id’ for tasks in an object passed to ‘push’
Hi @saimun, that’s definitely a cryptic error. Could you provide some more details about your route model hook (assuming that’s what is triggering this) and also the request payload that is coming from your server? The normalizeResponse method seems like it could be problematic but I’d have to see your payload to make any sort of better recommendation.
Ok I’d guess that the problem is your serializer, calling normalize from normalizeResponse is kinda short-circuiting some of the serializer logic. Since your payload doesn’t include type information you might be better off just extending the JSONSerializer like this:
import JSONSerializer from '@ember-data/serializer/json';
export default class TasksSerializer extends JSONSerializer { }
The RESTSerializer doesn’t do all that much on top of the JSONSerializer (which is confusingly named because there’s also the JSONAPISerializer) but it does expect your payload to have type wrapper(s):