cross-fetch
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -7,4 +7,3 @@ "use strict"; | ||
// Support schemaless URIs on the server for parity with the browser. | ||
// Ex: //github.com/ is converted to https://github.com/ | ||
// https://github.com/matthew-andrews/isomorphic-fetch/pull/10 | ||
// Ex: //github.com/ -> https://github.com/ | ||
if (/^\/\//.test(url)) { | ||
@@ -16,2 +15,4 @@ url = 'https:' + url; | ||
fetch.polyfill = false; | ||
module.exports = { | ||
@@ -18,0 +19,0 @@ fetch: fetch, |
{ | ||
"name": "cross-fetch", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Universal WHATWG Fetch API for Node, Browsers and React Native", | ||
"homepage": "https://github.com/lquixada/cross-fetch", | ||
"browser": "fetch-bundler.js", | ||
"browser": "dist/fetch-browser.js", | ||
"main": "fetch-node.js", | ||
"scripts": { | ||
"prepublish": "RU_ENV=production npm run build && npm test", | ||
"prepush": "npm test", | ||
"build": "npm run build:polyfill && npm run build:ponyfill", | ||
"build:polyfill": "RU_TYPE=polyfill rollup -c", | ||
"build:ponyfill": "RU_TYPE=ponyfill rollup -c", | ||
"test": "npm run lint && npm run mocha", | ||
"mocha": "mocha", | ||
"lint": "eslint ." | ||
"lint": "eslint .", | ||
"serve": "http-server" | ||
}, | ||
@@ -24,3 +29,2 @@ "repository": { | ||
"dependencies": { | ||
"fetch-ponyfill": "4.1.0", | ||
"node-fetch": "1.7.3", | ||
@@ -32,5 +36,10 @@ "whatwg-fetch": "2.0.3" | ||
"eslint": "4.7.2", | ||
"husky": "^0.14.3", | ||
"http-server": "0.10.0", | ||
"husky": "0.14.3", | ||
"mocha": "3.5.3", | ||
"nock": "9.0.19" | ||
"nock": "9.0.19", | ||
"rollup": "0.50.0", | ||
"rollup-plugin-commonjs": "8.2.1", | ||
"rollup-plugin-node-resolve": "3.0.0", | ||
"rollup-plugin-uglify": "2.0.1" | ||
}, | ||
@@ -37,0 +46,0 @@ "keywords": [ |
{ | ||
"name": "cross-fetch-polyfill", | ||
"version": "0.0.0", | ||
"browser": "fetch-bundler.js", | ||
"main": "fetch-node.js" | ||
"browser": "../dist/fetch-browser-polyfill.js", | ||
"main": "../fetch-node-polyfill.js" | ||
} |
@@ -7,3 +7,3 @@ cross-fetch | ||
Universal WHATWG Fetch API for Node, Browsers and React Native. The scenario that cross-fetch really shines is when your javascript codebase is shared between different platforms at the same time, for instance, an isomorphic app that runs on React Native. | ||
Universal WHATWG Fetch API for Node, Browsers and React Native. The scenario that cross-fetch really shines is when the same javascript codebase needs to run on different platforms. | ||
@@ -22,6 +22,6 @@ * * * | ||
// Using ES6 modules | ||
import fetch from 'cross-fetch'; | ||
import { fetch } from 'cross-fetch'; | ||
// Using CommonJS modules | ||
var fetch = require('cross-fetch'); | ||
const { fetch } = require('cross-fetch'); | ||
``` | ||
@@ -77,3 +77,10 @@ | ||
> ⚠️ **Warning**: If you're in an environment that doesn't support Promises such as Internet Explorer, you must install an ES6 Promise compatible polyfill. [es6-promise](https://github.com/jakearchibald/es6-promise) is suggested. | ||
## API | ||
You can find a comprehensive doc at [Github's fetch](https://github.github.io/fetch/) page. | ||
## FAQ | ||
@@ -83,21 +90,22 @@ | ||
My preferred library used to be [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch). It worked all and fine until the day I needed to expand my isomorphic app to React Native. It just threw an exception. I went to the github project and an [issue](https://github.com/matthew-andrews/isomorphic-fetch/issues/125) had already been filled. The repo however haven't received a single commit since 2016 leaving us orphans. A lot of forks has been created but each one addresses their particular problem be it cookies, older browsers support or whatever. | ||
I did a lot of research in order to find a fetch library that could meet theses criterias: | ||
In order to run a fetch that is cross-platform compatible, cross-fetch has been created. It is just the same as isomorphic-fetch but updated and that bug fixed. | ||
- [x] Simple import / require (no configuration required) | ||
- [x] Platform agnostic (client, server or react native) | ||
- [x] Optional polyfill (it's up to you if something is going to be added to the global object or not) | ||
#### How does it work? | ||
There's a plethora of libs out there but none could match those. | ||
cross-fetch (like isomorphic-fetch) is just a proxy. If you're in node, it delivers you the [node-fetch](https://www.npmjs.com/package/node-fetch) library, if you're in a browser ou React Native, it delivers you the github's [fetch-ponyfill](https://github.com/qubyte/fetch-ponyfill). | ||
#### Where can I find the API docs? | ||
#### Why not isomorphic-fetch? | ||
You can find a comprehensive doc at [Github's fetch](https://github.github.io/fetch/) page. | ||
My preferred library used to be [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch) but it has this [bug](https://github.com/matthew-andrews/isomorphic-fetch/issues/125) that prevents it from running in a react native environment. Also, polyfilling is mandatory. | ||
## Warning | ||
#### How does it work? | ||
* If you're in an environment that doesn't support Promises, you must bring your own ES6 Promise compatible polyfill. [es6-promise](https://github.com/jakearchibald/es6-promise) is suggested. | ||
cross-fetch (like isomorphic-fetch) is just a proxy. If you're in node, it delivers you the [node-fetch](https://www.npmjs.com/package/node-fetch) library, if you're in a browser ou React Native, it delivers you the github's [whatwg-fetch](https://github.com/github/fetch/). The same strategy applies if you're using polyfill or ponyfill. | ||
## Support | ||
## Suported environments | ||
@@ -112,5 +120,3 @@ * Node 4+ | ||
Note: modern browsers contain native implementations of `window.fetch`, therefore the code from this polyfill doesn't have any effect on those browsers. If you believe you've encountered an error with how `window.fetch` is implemented in any of these browsers, you should file an issue with that browser vendor instead of this project. | ||
## Thanks | ||
@@ -123,2 +129,2 @@ | ||
cross-fetch is licenced under the [MIT licence](https://github.com/lquixada/cross-fetch/blob/master/LICENSE). | ||
cross-fetch is licenced under the [MIT licence](https://github.com/lquixada/cross-fetch/blob/master/LICENSE) © [Leonardo Quixadá](https://twitter.com/lquixada/) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70767
2
20
206
125
10
2
3
14
- Removedfetch-ponyfill@4.1.0
- Removedfetch-ponyfill@4.1.0(transitive)