0

I'm relatively new to Ember.js and I'm trying to studing how ember works and I've this problem: from an Ember.js route I will call my django api like this: this.store.findAll('MYMODEL', 'ANOTHER_MODEL_ID')

This findAll will produce an api call like /mymodel/another_model_id/ where another_model_id is a dynamic id (uuid like string).

I've tried to override the findAll method with a custom adapter (mymodel adapter) that extends the ApplicationAdapter (JSONAPIAdapter with a custom buildUrl for adding trailing slash). But my attempt failed, because in findAll overridden method I can't reach the ANOTHER_MODEL_ID parameter. I've also tried to override urlForFindAll and buildUrl methods with the same results.

What is the best method for doing this kind of things and how can I do?

2 Answers 2

0

findAll has no id argument. Do you mean find('modelname', 'id')?

import DS from 'ember-data';

export default DS.Adapter.extend({
  findAll: function(store, type, sinceToken) {
    var query = { since: sinceToken };
    return new Ember.RSVP.Promise(function(resolve, reject) {
      Ember.$.getJSON(`/${type.modelName}`, query).then(function(data) {
        resolve(data);
      }, function(jqXHR) {
        reject(jqXHR);
      });
    });
  }
});
Sign up to request clarification or add additional context in comments.

Comments

0

I've resolved using urlForQuery function and declaring my adapter as JSONAPIAdapter extending it with DataAdapterMixin.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.