mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 02:15:43 +03:00
Always send region as a query param
This commit is contained in:
@@ -49,15 +49,18 @@ export default class ApplicationAdapter extends RESTAdapter {
|
||||
});
|
||||
}
|
||||
|
||||
ajaxOptions(url, type, options = {}) {
|
||||
ajaxOptions(url, verb, options = {}) {
|
||||
options.data || (options.data = {});
|
||||
if (this.get('system.shouldIncludeRegion')) {
|
||||
// Region should only ever be a query param. The default ajaxOptions
|
||||
// behavior is to include data attributes in the requestBody for PUT
|
||||
// and POST requests. This works around that.
|
||||
const region = this.get('system.activeRegion');
|
||||
if (region) {
|
||||
options.data.region = region;
|
||||
url = associateRegion(url, region);
|
||||
}
|
||||
}
|
||||
return super.ajaxOptions(url, type, options);
|
||||
return super.ajaxOptions(url, verb, options);
|
||||
}
|
||||
|
||||
// In order to remove stale records from the store, findHasMany has to unload
|
||||
@@ -119,3 +122,7 @@ export default class ApplicationAdapter extends RESTAdapter {
|
||||
return this.urlForFindRecord(...arguments);
|
||||
}
|
||||
}
|
||||
|
||||
function associateRegion(url, region) {
|
||||
return url.indexOf('?') !== -1 ? `${url}®ion=${region}` : `${url}?region=${region}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user