jeudi 16 février 2017

Ember urlForFindAll and BuildURL for DS.RESTAdapter prepend modelName value when overridden

This urlForFindAll function returns 'api/live/liveSites'. The GET request is made to 'site/api/live/liveSites' Where site is the modelName. I tried similar code with buildURL instead and had the same issue.

export default DS.RESTAdapter.extend({
  namespace: 'api',
  urlForFindAll: function (modelName, snapshot) {
    var url = this.namespace;
    if (snapshot.adapterOptions.siteType === 'live') {
      url += '/live/liveSites';
    } else {
       url +='/site/standard/standardSites';
    }
    return url;
  }
});

This is the call in question.

export default Ember.Route.extend({
  model () {
    return this.store.findAll('site', {
      adapterOptions: {
        siteType: 'live'
      }
    }).then(function (sites) {
      return sites.toArray();
    });
  }
})

Why is the url I return from urlForFindAll or BuildURL not the one to which the request is made?




Aucun commentaire:

Enregistrer un commentaire