npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@caspertech/async-request

v1.2.3

Published

async-request is a wrapper for request that uses ES7 async functions.

Downloads

4

Readme

async-request

NPM version Travis build status Dependency Status

Deprecated

Use either of the available and well maintained request libraries that implmenet Promise interface, e.g. https://github.com/joepie91/node-bhttp


async-request is a wrapper for request that uses ES7 async functions.

Usage

let request = require('async-request'),
    response;

try {
    response = await request('http://gajus.com/');

    // response.statusCode
    // response.headers
    // response.body

    await request('http://gajus.com', {
        // This example demonstrates all of the supported options.
        // Request method (uppercase): POST, DELETE, ...
        method: 'POST',
        data: {
            foo: 'bar'
        },
        headers: {
            foo: 'bar'
        },
        proxy: 'http://127.0.0.1:8000',
        // To create a new cookie jar.
        cookieJar: true,
        // To use a custom/existing cookie jar.
        // https://www.npmjs.com/package/tough-cookie
        cookieJar: new tough.CookieJar()
    });
} catch (e) {

}

// Returns a wrapper for the request using predefined custom options.
request = request.defaults({headers: {foo: 'bar'}});

// Returns the current default options.
request.defaults();
// {foo: 'bar'}

// Makes a HTTP GET request with {foo: 'bar'} headers.
await request('http://gajus.com');

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.