Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions packages/@orbit/jsonapi/src/jsonapi-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ import { PullOperator, PullOperators } from './lib/pull-operators';
import { getTransformRequests, TransformRequestProcessors } from './lib/transform-requests';
import { InvalidServerResponse } from './lib/exceptions';

if (typeof Orbit.globals.fetch !== 'undefined' && Orbit.fetch === undefined) {
Orbit.fetch = Orbit.globals.fetch.bind(Orbit.globals);
}

export interface FetchSettings {
headers?: object;
method?: string;
Expand Down Expand Up @@ -165,7 +161,7 @@ export default class JSONAPISource extends Source implements Pullable, Pushable
}

// console.log('fetch', fullUrl, mergedSettings, 'polyfill', fetch.polyfill);

let fetchFn = Orbit.fetch || fetch;
if (settings.timeout) {
let timeout = settings.timeout;
delete settings.timeout;
Expand All @@ -178,7 +174,7 @@ export default class JSONAPISource extends Source implements Pullable, Pushable
reject(new NetworkError(`No fetch response within ${timeout}ms.`));
}, timeout);

Orbit.fetch(fullUrl, settings)
fetchFn(fullUrl, settings)
.catch(e => {
Orbit.globals.clearTimeout(timer);

Expand All @@ -196,7 +192,7 @@ export default class JSONAPISource extends Source implements Pullable, Pushable
.then(resolve, reject);
});
} else {
return Orbit.fetch(fullUrl, settings)
return fetchFn(fullUrl, settings)
.catch(e => this.handleFetchError(e))
.then(response => this.handleFetchResponse(response));
}
Expand Down