Hi folks,
I set up a simple Ember Twiddle to show you my error that is occurring when trying to save a model.
It’s considerable that I’m using ember-cli-mirage
for mocking the data.
According to the docs, I created a shorthand route that should handle the PUT request.
It does, but with the error: Your handler for the url /api/shops/1 threw an error: Cannot convert undefined or null to object
When using the JSONAPISerializer, everything is working with shorthands (mirage/config.js
) and I’m able to update models, but in my case I have to use the RESTSerializer
with serialized IDs in the responses.
The request payload when I’m sending the model’s attrs
are without Id
at the end of the property name, f.e.:
// attrs object in PUT request
{
name: "Shop 1",
city: "1" // belongsTo relationship,
}
Now Mirage is trying to find those properties on the respective database model that has to be updated, but cannot find it, because in the database it’s cityId
and not just city
…
My question is: Is there a way to stick to shorthand route handlers only, or do I really have to write a helper or other custom solution, only because I have to use the RestSerializer? That would be really sad, but at least I would know then.
Thanks for your support!
ChrizzDF