Socket
Socket
Sign inDemoInstall

r2

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

r2

HTTP client. Spiritual successor to request.


Version published
Weekly downloads
63K
decreased by-7.4%
Maintainers
1
Weekly downloads
 
Created
Source

r2

Build Status Coverage Status Greenkeeper badge

Early in Node.js I wrote an HTTP client library called request. It evolved along with Node.js and eventually became very widely depended upon.

A lot has changed since 2010 and I've decided to re-think what a simple HTTP client library should look like.

This new library, r2, is a completely new approach from request.

  • Rather than being built on top of the Node.js Core HTTP library and shimmed for the browser, r2 is built on top of the browser's Fetch API and shimmed for Node.js.
  • APIs are meant to be used with async/await, which means they are based on promises.
const r2 = require('r2')

let html = await r2('https://www.google.com').text

Simple JSON support.

let obj = {ok: true}

let resp = await r2.put('http://localhost/test.json', {json: obj}).json

Simple headers support.

let headers = {'x-test': 'ok'}

let res = await r2('http://localhost/test', {headers}).response

Being written to the Fetch API is a huge benefit for browser users.

When running through browserify request is ~2M uncompressed and ~500K compressed. r2 is only 66K uncompressed and 16K compressed.

FAQs

Package last updated on 06 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc