Skip to content

Commit f0bcdc0

Browse files
committed
fix: removed core-js, fixed docs with async/await + then/catch usage
1 parent 2fd631a commit f0bcdc0

20 files changed

+26
-3935
lines changed

README.md

+25-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ yarn add superagent
4646
```js
4747
const superagent = require('superagent');
4848

49+
// callback
4950
superagent
5051
.post('/api/pet')
5152
.send({ name: 'Manny', species: 'cat' }) // sends a JSON post body
@@ -54,6 +55,19 @@ superagent
5455
.end((err, res) => {
5556
// Calling the end function will send the request
5657
});
58+
59+
// promise with then/catch
60+
superagent.post('/api/pet').then(console.log).catch(console.error);
61+
62+
// promise with async/await
63+
(async () => {
64+
try {
65+
const res = await superagent.post('/api/pet');
66+
console.log(res);
67+
} catch (err) {
68+
console.error(err);
69+
}
70+
})();
5771
```
5872

5973
### Browser
@@ -69,6 +83,8 @@ Browser-ready versions of this module are available via [jsdelivr][], [unpkg][],
6983
This is the solution for you if you're just using `<script>` tags everywhere!
7084

7185
```html
86+
<!-- https://github.com/Financial-Times/polyfill-service/issues/1944 -->
87+
<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.from%2CPromise%2CSymbol%2CObject.setPrototypeOf"></script>
7288
<script src="https://cdn.jsdelivr.net/npm/superagent"></script>
7389
<!-- if you wish to use unpkg.com instead: -->
7490
<!-- <script src="https://unpkg.com/superagent"></script> -->
@@ -141,7 +157,14 @@ If you are using [browserify][], [webpack][], [rollup][], or another bundler, th
141157

142158
### Required Browser Features
143159

144-
* IE9 requires a polyfill for `window.FormData` (we recommend [formdata-polyfill][])
160+
We recommend using <https://polyfill.io> (specifically with the bundle mentioned in [VanillaJS](#vanillajs) above):
161+
162+
```html
163+
<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.from%2CPromise%2CSymbol%2CObject.setPrototypeOf"></script>
164+
```
165+
166+
* IE 9-10 requires a polyfill for `Promise`, `Array.from`, `Symbol`, `Object.getOwnPropertySymbols`, and `Object.setPrototypeOf`
167+
* IE 9 requires a polyfill for `window.FormData` (we recommend [formdata-polyfill][])
145168

146169

147170
## Plugins
@@ -223,7 +246,7 @@ Our breaking changes are mostly in rarely used functionality and from stricter e
223246
[MIT](LICENSE) © TJ Holowaychuk
224247

225248

226-
##
249+
##
227250

228251
[npm]: https://www.npmjs.com/
229252

lib/agent-base.js

-25
This file was deleted.

0 commit comments

Comments
 (0)