Skip to content

Commit

Permalink
fix(request): fix binding of default global fetch
Browse files Browse the repository at this point in the history
AFFECTS PACKAGES:
@esri/arcgis-rest-request
  • Loading branch information
patrickarlt committed Sep 22, 2017
1 parent 6638a0c commit 6d04ded
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/arcgis-rest-request/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function request(
requestOptions?: IRequestOptions
): Promise<any> {
const options: IRequestOptions = {
...{ httpMethod: "POST", fetch },
...{ httpMethod: "POST", fetch: fetch.bind(Function("return this")()) },
...requestOptions
};

Expand Down
4 changes: 3 additions & 1 deletion packages/arcgis-rest-request/test/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ describe("request()", () => {
"https://www.arcgis.com/sharing/rest/content/items/43a8e51789044d9480a20089a84129ad/data"
);
expect(error.params).toEqual({ f: "json" });
expect(error.options).toEqual({ httpMethod: "POST", fetch });
expect(error.options.httpMethod).toEqual("POST");
expect(typeof error.options.fetch).toEqual("function");
expect(error.options.fetch.length).toEqual(2);
done();
});
});
Expand Down

0 comments on commit 6d04ded

Please sign in to comment.