Skip to content

Commit

Permalink
Support Ember.merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel Furniss committed Jun 14, 2017
1 parent 23ba2ae commit cf354ba
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions addon/mixins/adapter-fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,16 @@ export function headersToObject(headers) {
* @param {Object} options
*/
export function mungOptionsForFetch(_options, adapter) {
const options = (assign || merge)({
// This allows this mixin to be backward compatible with Ember < 2.5.
const combineObjs = (assign || merge);
const options = combineObjs({
credentials: 'same-origin',
}, _options);

let adapterHeaders = adapter.get('headers');
if (adapterHeaders) {
options.headers = assign({}, options.headers || {}, adapterHeaders);
// This double use of `combineObjs` is necessary because `merge` only accepts two arguments.
options.headers = combineObjs(combineObjs({}, options.headers || {}), adapterHeaders);
}
options.method = options.type;

Expand Down

0 comments on commit cf354ba

Please sign in to comment.