Reputation: 7148
I am working with an API which requires the use of reserved words, against the recommendation of the specification. I need to override the default behaviour of encoding the URL.
Here are my query params:
export default Ember.Mixin.create({
keywords: null,
genre: Ember.computed.alias("applicationController.genre"),
qualities: ["720p", "1080p", "3d"],
quality: "720p,1080p,3d",
queryParams: ["keywords", "page", "perPage", "genre", "sort", "quality"],
perPage: 50,
page: 1,
sort: "asc"
});
Currently, the request goes out with ,
characters replaced with %2c
. How can I keep my query param value for quality
?
Upvotes: 1
Views: 279
Reputation: 18240
You need to override ajaxOptions
on your adapter.
The default implementation gives the .data
directly to jQuery, and jQuery is doing the encoding of the query params then. Maybe somethis like this could do the job:
ajaxOptions() {
let hash = this._super(...arguments);
if(hash.data && hash.type === 'GET') {
hash.url += '?' + Object.keys(hash.data).map(key => {
return `${key}=${hash.data[key]}`;
}).join('&');
delete hash.data;
}
return hash;
}
Upvotes: 2