mardi 8 octobre 2019

Add a querystring to an Ember Data REST adapter

I'm working on an existing EmberJS app, and need to make a small maintenance on it. My cases consists in adding a querystring parameter to a RESTAdapter.

I found the adapter in the following shape:

export default DS.RESTAdapter.extend({

   pathForType() {
       return 'myendpoints/-/endpoint1';
   },

   updateRecord(store, type, snapshot) {
       return this._super(store, type, snapshot).then(() => {
         // reload the artifact
         this.ajax(this._buildURL('my-artifact', snapshot.id));
       });
   },
})

I initially tried simply appending the querystring to the return of pathForType method, although it built the final url in the shape: domain.com/myendpoints/-/endpoint1?query=string/

Am I missing any detail? I see in the docs examples that do it that way: https://api.emberjs.com/ember-data/3.10/classes/DS.BuildURLMixin/methods?anchor=urlForUpdateRecord




Aucun commentaire:

Enregistrer un commentaire