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
datashould be an array -- is it not? Is it under a field likedata.results? Can you show a sample response?Object student: Array[3] 0: Object s_id: 1 surname: "Jones" __proto__: Object 1: Object s_id: 2 surname: "Smith" __proto__: Object 2: Object s_id: 3 surname: "Biggins" __proto__: Object length: 3 __proto__: Array[0] __proto__: Objectsorry for the formatting issuesdata.studentis the array of students you want to load into the store, notdata. Is this correct?DS.RestAdapterdoes assume the pluralized form as the root of the json in its implementation offindAll, but if you need this, you should either mimic this implementation or just use/extend that built-in one.