Tutorial -> Ember Data -> Incorrect usage of Mirage
The documentation in this talks about:
Let's now configure Mirage to send back our rentals that we had defined above by updating mirage/config.js
This is actually located at app/mirage/config.js
In addition (apologies if this should be a separate issue), the content of config.js is shown as:
this.get('/rentals', function() {
return {
data: [{
type: "rentals",
....
When I use this, I get the following output in my Chrome console:
WARNING: Encountered "data" in payload, but no model was found for model name "datum" (resolved model name using super-rentals@serializer:-rest:.modelNameFromPayloadKey("data"))
I changed data to rentals in the rentals array. I.e.
this.get('/rentals', function() {
return {
rentals: [{
type: "rentals",
....
This hasn't solved the issue in that the data is still not being rendered in the sample website, but at least it's stopped the console error and is looping over each item in the array.
In the sample data used in the config.js, the data required is organised like this:
type: "rentals",
id: 2,
attributes: {
title: "Urban Living",
....
}
The model and data usage is set up to work without the attributes nested object, like
type: "rentals",
id: 2,
title: "Urban Living",
....
}
I don't know enough yet to understand what the best practice solution for that is; whether there should be a different model definition, some kind of transform, or if for the sake of the tutorial whether we should just change the data format. I'm changing the data format so I can continue.
@JonForest Could you open this issue on the Guides repo instead? That is more actively watched than this repo ... https://github.com/emberjs/guides/issues :+1:
Cool. Will do. Cheers.
@JonForest change ember-data version to 2.0 in bower.json and install bower again.version incompatibility between ember and ember-data because of this problem in loading data
@jprassanakumar I was running into the same problem when doing an ember cli tutorial (http://www.thetechcofounder.com/getting-started-with-ember-js-using-ember-cli/). Your suggestion works perfectly for me :+1:
@jprassanakumar @TifPun there's a whole paragraph about making sure you have the proper dependencies. I'll try making it more noticeable.
@JonForest Thank you for posting those fixes. I slammed into these today.
Thanks @jprassanakumar, fixed the problem for me
Thanks @jprassanakumar, fixed the problem for me
It may be the version issue, but it can be fixed by changing data -> rentals, and removing type:'rentals'. return { rentals: [{ id: 'grand-old-mansion', title: 'Grand Old Mansion', .... type: 'Estate', .... } ]