Skip to content

Commit 7ccc41e

Browse files
authored
ReadME
1 parent ef0514f commit 7ccc41e

File tree

1 file changed

+0
-136
lines changed

1 file changed

+0
-136
lines changed

README.md

Lines changed: 0 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
cross-fetch<br>
2-
[![NPM Version](https://img.shields.io/npm/v/cross-fetch.svg?branch=main)](https://www.npmjs.com/package/cross-fetch)
3-
[![Downloads Per Week](https://img.shields.io/npm/dw/cross-fetch.svg?color=blue)](https://www.npmjs.com/package/cross-fetch)
4-
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5-
[![CI](https://github.com/lquixada/cross-fetch/actions/workflows/ci.yml/badge.svg)](https://github.com/lquixada/cross-fetch/actions/workflows/ci.yml)
6-
[![codecov](https://codecov.io/gh/lquixada/cross-fetch/branch/main/graph/badge.svg)](https://codecov.io/gh/lquixada/cross-fetch)
7-
================
8-
91
Universal WHATWG Fetch API for Node, Browsers, Workers and React Native. The scenario that cross-fetch really shines is when the same JavaScript codebase needs to run on different platforms.
102

113
- **Platform agnostic**: browsers, Node or React Native
@@ -15,118 +7,6 @@ Universal WHATWG Fetch API for Node, Browsers, Workers and React Native. The sce
157
- **TypeScript support**: better development experience with types.
168
- **Worker support**: works on different types of workers such as Service Workers and CloudFlare Workers
179

18-
19-
* * *
20-
21-
## Table of Contents
22-
23-
- [Install](#install)
24-
- [Usage](#usage)
25-
- [Demo \& API](#demo--api)
26-
- [FAQ](#faq)
27-
- [Yet another fetch library?](#yet-another-fetch-library)
28-
- [Why polyfill might not be a good idea?](#why-polyfill-might-not-be-a-good-idea)
29-
- [How does cross-fetch work?](#how-does-cross-fetch-work)
30-
- [Who's Using It?](#whos-using-it)
31-
- [Thanks](#thanks)
32-
- [License](#license)
33-
- [Author](#author)
34-
35-
* * *
36-
37-
## Install
38-
39-
```sh
40-
npm install --save cross-fetch
41-
```
42-
43-
As a [ponyfill](https://github.com/sindresorhus/ponyfill) (imports locally):
44-
45-
```javascript
46-
// Using ES6 modules with Babel or TypeScript
47-
import fetch from 'cross-fetch';
48-
49-
// Using CommonJS modules
50-
const fetch = require('cross-fetch');
51-
```
52-
53-
As a polyfill (installs globally):
54-
55-
```javascript
56-
// Using ES6 modules
57-
import 'cross-fetch/polyfill';
58-
59-
// Using CommonJS modules
60-
require('cross-fetch/polyfill');
61-
```
62-
63-
64-
The CDN build is also available on unpkg:
65-
66-
```html
67-
<script src="//unpkg.com/cross-fetch/dist/cross-fetch.js"></script>
68-
```
69-
70-
This adds the fetch function to the window object. Note that this is not UMD compatible.
71-
72-
73-
* * *
74-
75-
## Usage
76-
77-
With [promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise):
78-
79-
```javascript
80-
import fetch from 'cross-fetch';
81-
// Or just: import 'cross-fetch/polyfill';
82-
83-
fetch('//api.github.com/users/lquixada')
84-
.then(res => {
85-
if (res.status >= 400) {
86-
throw new Error("Bad response from server");
87-
}
88-
return res.json();
89-
})
90-
.then(user => {
91-
console.log(user);
92-
})
93-
.catch(err => {
94-
console.error(err);
95-
});
96-
```
97-
98-
With [async/await](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function):
99-
100-
```javascript
101-
import fetch from 'cross-fetch';
102-
// Or just: import 'cross-fetch/polyfill';
103-
104-
(async () => {
105-
try {
106-
const res = await fetch('//api.github.com/users/lquixada');
107-
108-
if (res.status >= 400) {
109-
throw new Error("Bad response from server");
110-
}
111-
112-
const user = await res.json();
113-
114-
console.log(user);
115-
} catch (err) {
116-
console.error(err);
117-
}
118-
})();
119-
```
120-
121-
## Demo & API
122-
123-
You can find a comprehensive doc at [Github's fetch](https://github.github.io/fetch/) page. If you want to play with cross-fetch, check our [**JSFiddle playground**](https://jsfiddle.net/lquixada/3ypqgacp/).
124-
125-
> **Tip**: Run the fiddle on various browsers and with different settings (for instance: cross-domain requests, wrong urls or text requests). Don't forget to open the console in the test suite page and play around.
126-
127-
128-
## FAQ
129-
13010
#### Yet another fetch library?
13111

13212
I did a lot of research in order to find a fetch library that could be simple, cross-platform and provide polyfill as an option. There's a plethora of libs out there but none could match those requirements.
@@ -146,19 +26,3 @@ Just like isomorphic-fetch, it is just a proxy. If you're in node, it delivers y
14626
|:---:|:---:|:---:|:---:|:---:|:---:|
14727
|The New York Times|Apollo GraphQL|Facebook|Swagger|VulcanJS|graphql-request|
14828

149-
150-
## Thanks
151-
152-
Heavily inspired by the works of [matthew-andrews](https://github.com/matthew-andrews). Kudos to him!
153-
154-
155-
## License
156-
157-
cross-fetch is licensed under the [MIT license](https://github.com/lquixada/cross-fetch/blob/main/LICENSE) © [Leonardo Quixadá](https://twitter.com/lquixada/)
158-
159-
160-
## Author
161-
162-
|[![@lquixada](https://avatars0.githubusercontent.com/u/195494?v=4&s=96)](https://github.com/lquixada)|
163-
|:---:|
164-
|[@lquixada](http://www.github.com/lquixada)|

0 commit comments

Comments
 (0)