diff --git a/ui/app/adapters/application.js b/ui/app/adapters/application.js index e03cdffe3..a2f977aee 100644 --- a/ui/app/adapters/application.js +++ b/ui/app/adapters/application.js @@ -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}`; +}