-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 31f67b1
Showing
5 changed files
with
56 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Fetch-register | ||
|
||
_Fetch just works_ | ||
|
||
Add [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) globally on any js environment. | ||
|
||
## Usage | ||
|
||
Add once in beginning of your project | ||
|
||
```js | ||
require("fetch-register"); | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const realFetch = require("node-fetch"); | ||
module.exports = function(url, options) { | ||
if (/^\/\//.test(url)) { | ||
url = "https:" + url; | ||
} | ||
return realFetch.call(this, url, options); | ||
}; | ||
|
||
if (!global.fetch) { | ||
global.fetch = module.exports; | ||
global.Response = realFetch.Response; | ||
global.Headers = realFetch.Headers; | ||
global.Request = realFetch.Request; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "fetch-register", | ||
"version": "1.0.0", | ||
"description": "Fetch just works", | ||
"main": "index.js", | ||
"scripts": {}, | ||
"keywords": [ | ||
"fetch" | ||
], | ||
"author": "Han Lin Yap (http://yap.nu)", | ||
"license": "ISC", | ||
"dependencies": { | ||
"node-fetch": "^2.2.0" | ||
} | ||
} |