I receive the error
Uncaught TypeError: Object #<Object> has no method 'map'
when using ember-data to try and load the json from my api.
App = Ember.Application.create({});
App.Student = DS.Model.extend({
primaryKey: 's_id',
s_id: DS.attr('integer'),
surname: DS.attr('string')
});
App.Student.reopenClass({
url: 'api/student.php'
})
App.adapter = DS.Adapter.create({
findAll: function(store, type) {
var url = type.url;
console.log(type.url);
jQuery.getJSON(url, function(data){
store.loadMany(type, data);
});
}
});
App.store = DS.Store.create({
revision: 4,
adapter: App.adapter
});
App.students = App.store.findAll(App.Student);
I’ve made sure the JSON is the correct format but to no avail; any ideas?
Thanks
pauldechov answered this in a comment above:
Because the root of the json is named, I can call data.student to get call loadMany correctly.