async-http-request
Simply wrapped request with Promise, so you can use async/await of ES7.
Installation
Using npm:
$ npm i -D async-http-request
Usage
Resolve with response data
"use strict"; const asyncRequest = ;const url = "http://www.google.com"; { // Resolved with response data let body = await ; console;};
http.IncomingMessage
Resolve with response object, instance ofNote, await could only be used in async function. See async & await
"use strict"; const asyncRequest = ;const url = "http://www.google.com";const resolveWithResponse = true; { // Resolved with response object let response = await ; console; console;};
request returned
Resolve with raw object as same asWith this object, you can use all methods that doc shows
"use strict"; const asyncRequest = ;const request = ;const fs = ; const url = "http://www.google.com";const resolveWithRequest = true; { // Resolved with response object let oReq = await ; console; // Sample 1, pipe stream oReq; // Sample 2, events oReq ;};
Error handling, resolve with Error
"use strict"; const asyncRequest = ;const url = "http://www.google.com"; { // Something wrong like net work issue let err = await ; console;};
request
Convenience methods of"use strict"; const asyncRequest = ;const url = "http://www.google.com"; { // Something wrong like net work issue let body_get = await asyncRequest; console; let body_post = await asyncRequest; console;};