Socket
Socket
Sign inDemoInstall

cross-fetch

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cross-fetch - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

package.json
{
"name": "cross-fetch",
"version": "1.1.0",
"version": "1.1.1",
"description": "Universal WHATWG Fetch API for Node, Browsers and React Native",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/lquixada/cross-fetch",

@@ -14,3 +14,2 @@ cross-fetch

- **Updated**: lastest version of whatwg-fetch and node-fetch used
- **Small**: 2.5kb gzipped

@@ -73,6 +72,7 @@

As a [ponyfill](https://github.com/sindresorhus/ponyfill):
With [promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise):
```javascript
const fetch = require('cross-fetch');
import fetch from 'cross-fetch';
// Or just: import 'cross-fetch/polyfill';

@@ -88,20 +88,29 @@ fetch('//api.github.com/users/lquixada')

console.log(user);
})
.catch(err => {
console.error(err);
});
```
As a polyfill:
With [async/await](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function):
```javascript
require('cross-fetch');
import fetch from 'cross-fetch';
// Or just: import 'cross-fetch/polyfill';
fetch('//api.github.com/users/lquixada')
.then(res => {
(async () => {
try {
const res = await fetch('//api.github.com/users/lquixada');
if (res.status >= 400) {
throw new Error("Bad response from server");
}
return res.json();
})
.then(user => {
const user = await res.json();
console.log(user);
});
} catch (err) {
console.error(err);
}
})();
```

@@ -144,2 +153,3 @@

* [graphql-request](https://github.com/graphcool/graphql-request)
* [Swagger](https://swagger.io/)

@@ -146,0 +156,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc