samedi 30 avril 2016

Cannot read property 'type' of undefined

I tried setting my app in ember@2.5.0, but every time when I use store and try to use

this.store.findAll("user");

I always get the error saying Cannot read property 'type' of undefined.

Initialized the store, adapter and the model and server too.

adapters/application.js

import JSONAPIAdapter from 'ember-data/adapters/json-api';
export default JSONAPIAdapter.extend({
    defaultSerialiser: "-default"
});

models/user.js

import Model from 'ember-data/model';
import attr from 'ember-data/attr'
export default Model.extend({
    "name": attr()
});

and server side it is like

app.get("/users", function(req, res) {
    res.send({"name": "Surya"});
});

Getting error

TypeError: Cannot read property 'type' of undefined
at _pushInternalModel (store.js:1524)
at push (store.js:1501)
at finders.js:148
at Object.Backburner.run (ember.debug.js:678)
at _adapterRun (store.js:1733)
at finders.js:145
at tryCatch (ember.debug.js:53806)
at invokeCallback (ember.debug.js:53821)
at publish (ember.debug.js:53789)
at ember.debug.js:32054




Aucun commentaire:

Enregistrer un commentaire