-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support for custom RequestInit
- Loading branch information
1 parent
9777c09
commit d2ae11a
Showing
3 changed files
with
21 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
import fetch from 'node-fetch'; | ||
import fetch, { RequestInit } from 'node-fetch'; | ||
|
||
export async function resolveHttp(ref: uri.URI) { | ||
const response = await fetch(String(ref)); | ||
export async function resolveHttp(ref: uri.URI, opts: RequestInit = {}) { | ||
const response = await fetch(String(ref), opts); | ||
return response.text(); | ||
} | ||
|
||
export function createResolveHttp(defaultRequestOptions: RequestInit = {}) { | ||
return (ref: uri.URI) => resolveHttp(ref, defaultRequestOptions); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { resolveHttp } from './http'; | ||
export { createResolveHttp, resolveHttp } from './http'; | ||
export { resolveFile } from './file'; |