async-request
async-request is a wrapper for request that uses ES7 async functions.
Usage
let request = response; try response = await ; // response.statusCode // response.headers // response.body await ; catch e // Returns a wrapper for the request using predefined custom options.request = request; // Returns the current default options.request;// {foo: 'bar'} // Makes a HTTP GET request with {foo: 'bar'} headers.await ;
Debugging
async-request
does not provide (expose) inbuilt debugging capabilities. Use a proxy (e.g. https://mitmproxy.org/) to intercept and analyze HTTP traffic.
API
- Make sure API is based on https://fetch.spec.whatwg.org/ standard.
Running
Async function behavior has been accepted into stage 1 ("Proposal") of the ECMASCript 7 spec process in January 2014. This means that it cannot be used out of the box with node.js or iojs without a transpiler.
This library is using Babel to compile ES7 code into ES5. Refer to the ./gulpfile.js.
Beware
This library has been created as part of ES7 async function proposal research. It covers basic use of request. I do not advise to use it in production, though I will be testing it in several private projects and update as I go – contributions are welcome too.