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

futoin-request

v2.1.2

Published

AsyncSteps friendly wrapper of 'request' package

Downloads

5

Readme

NPM Version NPM Downloads Build Status stable

NPM

About

FutoIn AsyncSteps friendly wrapper of request.

Documentation --> FutoIn Guide

Author: Andrey Galkin

Installation for Node.js

Command line:

$ npm install futoin-request --save

or:

$ yarn add futoin-request --save

Browser installation

The module can be used with webpack or any other CommonJS packer. However, please ensure to use ES6->ES5 transpilation for older browsers.

Pre-packed UMD module is available in dist/futoin-request.js (stripped ~180KB from over 1MB).

Note: please note that pre-packed dist is heavily stripped of dependencies and most features of request library is not expected to work due not minimal use case in browsers:

  • MIME type detection based on upload file name
  • AWS request signing feature
  • HAR feature
  • HTTP Signature feature
  • HAWK feature
  • Proxy/Tunnel feature
  • HTTP digest auth (large crypto dependency)
  • OAuth
  • tough-cookie

You can always use own webpack build.

Examples

const $as = require('futoin-asyncsteps');
const $as_request = require('futoin-request');

$as().add((as) => {
    // Very basic
    $as_request(as, 'https://httpbin.org/get');
    as.add((as, rsp, body) => console.log(body));
    
    // As usual
    $as_request.post(as, {
        url: 'https://httpbin.org/post',
        json: {a: 1, b: 2},
    });
    as.add((as, rsp, body) => console.log(body));
    
    // With callback for request as stream manipulation
    $as_request.post(as, {
        url: 'https://httpbin.org/post',
        headers: { 'content-length': 4 },
    }, (req) => req.end('test') );
    as.add((as, rsp, body) => console.log(body));    
}).execute();

API documentation

API is absolutely the same as for original request package except that:

  1. The first parameter must be a reference of AsyncSteps interface type.
  2. A next step receiving (as, rsp, body) => {} must be added instead of result callback.
  3. Error is thrown through AsyncSteps#error(), if detected.
  4. HTTP status != 200 is error as well.
  5. Request object is not returned, but passed to optional callback (third argument).

Additional notes:

  • Request is properly canceled on AsyncSteps#cancel() or timeout
  • Error info details
    • error type - RequestError
    • error object should be available through standard as.state.last_exception convention
    • as.state.last_response is set with response object
  • Browser provides $as_request global reference

Members

request

window.FutoIn.request - browser-only reference to futoin-request module

Kind: global variable

$as_request

window.$as_request - browser-only reference to futoin-request module

Kind: global variable