Skip to content

Instantly share code, notes, and snippets.

@seancribbs
Last active January 2, 2016 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seancribbs/8300937 to your computer and use it in GitHub Desktop.
Save seancribbs/8300937 to your computer and use it in GitHub Desktop.
DS.RESTAdapter.reopen({
fetchBatchSize: 25,
findMany: function(store, type, ids, owner){
var root = type.typeKey,
batchSize = this.get('fetchBatchSize') || ids.length,
batch,
rest = ids,
promises = [],
key = this.pathForType(root);
while(rest.length > 0){
batch = rest.slice(0, batchSize);
rest = rest.slice(batchSize);
promises.push(this.ajax(this.buildURL(root), "GET", {
data: { ids: batch }
}));
}
return Ember.RSVP.all(promises).then(function(results){
return results.reduce(function(acc, item){
acc[key] = acc[key].concat(item[key]);
return acc;
});
});
},
pathForType: function(type){
return type.pluralize().underscore();
}
});

Assertion failed: The response from a findMany must be an Array, not undefined

Here's the line it points to (the assertion):

function _findMany(adapter, store, type, ids, owner) {
  var promise = adapter.findMany(store, type, ids, owner),
      serializer = serializerForAdapter(adapter, type);

  return resolve(promise, "DS: Handle Adapter#findMany of " + type).then(function(payload) {
    payload = serializer.extract(store, type, payload, null, 'findMany');

    Ember.assert("The response from a findMany must be an Array, not " + Ember.inspect(payload), Ember.typeOf(payload) === 'array');

    store.pushMany(type, payload);
  }, null, "DS: Extract payload of " + type);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment