From 3c99a803378e5917ef6cbfa9766df87dbd703bee Mon Sep 17 00:00:00 2001 From: Franck Romano Date: Fri, 4 Oct 2019 11:04:05 +0200 Subject: [PATCH] add documentation about how to use async/await with request-promise --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 564d3ef..6bb4b31 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,21 @@ rp(options) }); ``` +### Using async/await + +Since `async/await` is a wrapper around `promises`, you can use `async/await` with `request-promise` + +``` js +async function crawlWebpage () { + try { + const htmlString = await rp('http://www.google.com') + // Process html... + } catch (err) { + // Crawling failed... + } +} +``` + ### GET something from a JSON REST API ``` js