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.
r2is built on top of the browser's Fetch API and shimmed for Node.js.
const r2 =let html = await text
Simple JSON support.
let obj = ok: truelet resp = await r2json
Simple headers support.
let headers = 'x-test': 'ok'let res = await 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.