If I extend adapter in app/adapters/application.js
let appAdapter = DS.RESTAdapter.extend({
ajax: function(url, method, hash) {
hash = hash || {};
hash.crossDomain = true;
hash.xhrFields = {
withCredentials: true
};
return this._super(url, method, hash);
},
});
export default appAdapter.reopen(config.adapterSettings);
it will still be superseded by model specific Adapters which I also have.
I have a few specific Adapters, for example: app/adapters/testpost.js
export default DS.RESTAdapter.extend(myTemplates, {
myTemplate: `${host}/${dir}/testpost`,
});
For now to make it work, I extended each of them with the same piece of code, for example app/adapters/testpost.js became:
let testpostAdapter = DS.RESTAdapter.extend({
ajax: function(url, method, hash) {
hash = hash || {};
hash.crossDomain = true;
hash.xhrFields = {
withCredentials: true
};
return this._super(url, method, hash);
},
});
export default testpostAdapter.extend(myTemplates, {
myTemplate: `${host}/${dir}/testpost`,
});
The question: How to extend/rewrite RESTAdapter for all Ember, and for all specific adapters at once.
Tried to extend in app/app.js, doesn't work that way.
Aucun commentaire:
Enregistrer un commentaire