Skip to content

Commit 52d6945

Browse files
authored
Add promise support section to README (#2605)
1 parent b12a624 commit 52d6945

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ request('http://www.google.com', function (error, response, body) {
2828
## Table of contents
2929

3030
- [Streaming](#streaming)
31+
- [Promises & Async/Await](#promises--asyncawait)
3132
- [Forms](#forms)
3233
- [HTTP Authentication](#http-authentication)
3334
- [Custom HTTP Headers](#custom-http-headers)
@@ -142,6 +143,22 @@ You can still use intermediate proxies, the requests will still follow HTTP forw
142143
---
143144

144145

146+
## Promises & Async/Await
147+
148+
`request` supports both streaming and callback interfaces natively. If you'd like `request` to return a Promise instead, you can use an alternative interface wrapper for `request`. These wrappers can be useful if you prefer to work with Promises, or if you'd like to use `async`/`await` in ES2017.
149+
150+
Several alternative interfaces are provided by the request team, including:
151+
- [`request-promise`](https://github.com/request/request-promise) (uses [Bluebird](https://github.com/petkaantonov/bluebird) Promises)
152+
- [`request-promise-native`](https://github.com/request/request-promise-native) (uses native Promises)
153+
- [`request-promise-any`](https://github.com/request/request-promise-any) (uses [any-promise](https://www.npmjs.com/package/any-promise) Promises)
154+
155+
156+
[back to top](#table-of-contents)
157+
158+
159+
---
160+
161+
145162
## Forms
146163

147164
`request` supports `application/x-www-form-urlencoded` and `multipart/form-data` form uploads. For `multipart/related` refer to the `multipart` API.

0 commit comments

Comments
 (0)