isomorphic-unfetch
Advanced tools
Comparing version 3.1.0 to 4.0.2
19
index.js
@@ -1,6 +0,13 @@ | ||
function r(m){return m && m.default || m;} | ||
module.exports = global.fetch = global.fetch || ( | ||
typeof process=='undefined' ? r(require('unfetch')) : (function(url, opts) { | ||
return r(require('node-fetch'))(String(url).replace(/^\/\//g,'https://'), opts); | ||
}) | ||
); | ||
function r(m) { | ||
return (m && m.default) || m; | ||
} | ||
module.exports = global.fetch = | ||
global.fetch || | ||
(typeof process == "undefined" | ||
? r(require("unfetch")) | ||
: function (url, opts) { | ||
if (typeof url === "string" || url instanceof URL) { | ||
url = String(url).replace(/^\/\//g, "https://"); | ||
} | ||
return import("node-fetch").then((m) => r(m)(url, opts)); | ||
}); |
{ | ||
"name": "isomorphic-unfetch", | ||
"version": "3.1.0", | ||
"version": "4.0.2", | ||
"description": "Switches between unfetch & node-fetch for client & server.", | ||
"files": [ | ||
"index.js", | ||
"index.d.ts", | ||
"browser.js" | ||
], | ||
"exports": { | ||
".": { | ||
"import": "./index.mjs", | ||
"default": "./index.js" | ||
}, | ||
"./browser": { | ||
"import": "./browser.mjs", | ||
"default": "./browser.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"license": "MIT", | ||
@@ -16,5 +22,5 @@ "repository": "developit/unfetch", | ||
"dependencies": { | ||
"node-fetch": "^2.6.1", | ||
"unfetch": "^4.2.0" | ||
"node-fetch": "^3.2.0", | ||
"unfetch": "^5.0.0" | ||
} | ||
} |
@@ -9,2 +9,4 @@ # Isomorphic Unfetch | ||
> **Note:** This module uses node-fetch 3.x, which is ES Module and requires Node >= 12.20.0. | ||
```sh | ||
@@ -18,6 +20,6 @@ $ npm i isomorphic-unfetch | ||
// using ES6 modules | ||
import fetch from 'isomorphic-unfetch' | ||
import fetch from "isomorphic-unfetch"; | ||
// using CommonJS modules | ||
const fetch = require('isomorphic-unfetch') | ||
const fetch = require("isomorphic-unfetch"); | ||
``` | ||
@@ -30,7 +32,7 @@ | ||
```js | ||
import fetch from 'isomorphic-unfetch'; | ||
import fetch from "isomorphic-unfetch"; | ||
fetch('/foo.json') | ||
.then( r => r.json() ) | ||
.then( data => { | ||
fetch("/foo.json") | ||
.then((r) => r.json()) | ||
.then((data) => { | ||
console.log(data); | ||
@@ -43,9 +45,9 @@ }); | ||
```js | ||
import 'isomorphic-unfetch'; | ||
import "isomorphic-unfetch"; | ||
// "fetch" is now installed globally if it wasn't already available | ||
fetch('/foo.json') | ||
.then( r => r.json() ) | ||
.then( data => { | ||
fetch("/foo.json") | ||
.then((r) => r.json()) | ||
.then((data) => { | ||
console.log(data); | ||
@@ -52,0 +54,0 @@ }); |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
3378
7
47
56
1
+ Addeddata-uri-to-buffer@4.0.1(transitive)
+ Addedfetch-blob@3.2.0(transitive)
+ Addedformdata-polyfill@4.0.10(transitive)
+ Addednode-domexception@1.0.0(transitive)
+ Addednode-fetch@3.3.2(transitive)
+ Addedunfetch@5.0.0(transitive)
+ Addedweb-streams-polyfill@3.3.3(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedunfetch@4.2.0(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
Updatednode-fetch@^3.2.0
Updatedunfetch@^5.0.0