I have function in my adapter "findQuery" the function need to GET data from the server and return it.
the function:
findQuery: function(store, type, query) {
var userId = query['user_id'];
delete query['user_id'];
if (this.sortQueryParams) {
query = this.sortQueryParams(query);
}
var adapter = this;
// Create nested url
//return this.ajax(this.urlPrefix(this.pathForType(type.typeKey), this.buildURL(type, userId)), 'GET', { data: query });
// We would like to relate the rows to the connected user
return new Ember.RSVP.Promise(function(resolve, reject) {
adapter.ajax(adapter.buildURL(type.typeKey, null, userId), 'GET', { data: query }).then(function(devices) {
store.find('user', userId).then(function(user) {
devices.setEach('user_id', user);
resolve(devices); // devices is set exactly as i wanted!
}, function(failed) {
reject(failed);
});
}, function(error) {
reject(error);
});
});
}
so when I debug the function Ii see that the function get into the resolve with the correct data (the API returned all the requested data as Array of objects). And then I get log Error:
Error: Assertion Failed: The response from a findQuery must be an Array, not undefined
What could be the issue?
Aucun commentaire:
Enregistrer un commentaire