Skip to content

Commit

Permalink
Merge pull request #621 from tchak/override-fetch
Browse files Browse the repository at this point in the history
Extract appendQueryParams in its own method
  • Loading branch information
dgeb authored Apr 15, 2019
2 parents ca1c317 + f387a33 commit 8d1acb2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/@orbit/jsonapi/src/jsonapi-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,7 @@ export default class JSONAPISource extends Source implements Pullable, Pushable,

fetch(url: string, customSettings?: FetchSettings): Promise<any> {
let settings = this.initFetchSettings(customSettings);

let fullUrl = url;
if (settings.params) {
fullUrl = appendQueryParams(fullUrl, settings.params);
delete settings.params;
}
let fullUrl = this.appendQueryParams(url, settings);

let fetchFn = (Orbit as any).fetch || Orbit.globals.fetch;

Expand Down Expand Up @@ -245,6 +240,15 @@ export default class JSONAPISource extends Source implements Pullable, Pushable,
return settings;
}

protected appendQueryParams(url: string, settings: FetchSettings): string {
let fullUrl = url;
if (settings.params) {
fullUrl = appendQueryParams(fullUrl, settings.params);
delete settings.params;
}
return fullUrl;
}

protected async handleFetchResponse(response: Response): Promise<any> {
if (response.status === 201) {
if (this.responseHasContent(response)) {
Expand Down

0 comments on commit 8d1acb2

Please sign in to comment.