Based on the documentation here: http://ift.tt/1WGabbV JSONSerializer is the right serializer for me to use for my API.
Despite that I receive the following error:
ember.debug.js:28535 Error while processing route: core.admin.users Cannot read property 'type' of undefined TypeError: Cannot read property 'type' of undefined
The API response looks like this:
{
"errors": [],
"data": [
{
"first_name": "Foo",
"last_name": "Bar"
},
{
"first_name": "Moo",
"last_name": "Boo"
}
],
"version": 1
}
My Model looks like so:
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
export default Model.extend({
first_name: attr('string'),
last_name: attr('string')
});
My Application Adapter:
import RESTAdapter from 'ember-data/adapters/rest';
export default RESTAdapter.extend({
headers: {
'Accepts': 'application/json',
'Accept': 'application/json'
}
});
My User Adapter:
import ApplicationAdapter from './application';
export default ApplicationAdapter.extend({
buildURL: function(){
return 'core/users/foobar';
}
});
And finally my application Serializer:
import JSONSerializer from 'ember-data/serializers/json';
export default JSONSerializer.extend({
});
Aucun commentaire:
Enregistrer un commentaire