Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement isomorphic fetch #458

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
18 changes: 17 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"@octokit/endpoint": "^7.0.0",
"@octokit/request-error": "^3.0.0",
"@octokit/types": "^6.16.1",
"cross-fetch": "^3.1.5",
"is-plain-object": "^5.0.0",
"node-fetch": "^2.6.7",
"universal-user-agent": "^6.0.0"
},
"devDependencies": {
Expand Down
7 changes: 4 additions & 3 deletions src/fetch-wrapper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isPlainObject } from "is-plain-object";
import nodeFetch, { HeadersInit, Response } from "node-fetch";
import isomorphicFetch, { Response } from "cross-fetch";
import { HeadersInit } from "node-fetch";
import { RequestError } from "@octokit/request-error";
import { EndpointInterface } from "@octokit/types";

Expand All @@ -26,8 +27,8 @@ export default function fetchWrapper(
let status: number;
let url: string;

const fetch: typeof nodeFetch =
(requestOptions.request && requestOptions.request.fetch) || nodeFetch;
const fetch: typeof isomorphicFetch =
(requestOptions.request && requestOptions.request.fetch) || isomorphicFetch;

return fetch(
requestOptions.url,
Expand Down
2 changes: 1 addition & 1 deletion src/get-buffer-response.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Response } from "node-fetch";
import { Response } from "cross-fetch";
export default function getBufferResponse(response: Response) {
return response.arrayBuffer();
}
3 changes: 2 additions & 1 deletion test/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import stream from "stream";

import { getUserAgent } from "universal-user-agent";
import fetchMock from "fetch-mock";
import { Headers, RequestInit } from "node-fetch";
import { Headers } from "cross-fetch";
import { RequestInit } from "node-fetch";
import { createAppAuth } from "@octokit/auth-app";
import lolex from "lolex";
import {
Expand Down