Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikeal/r2
HTTP client. Spiritual successor to request.
https://github.com/mikeal/r2
Last synced: about 1 month ago
JSON representation
HTTP client. Spiritual successor to request.
- Host: GitHub
- URL: https://github.com/mikeal/r2
- Owner: mikeal
- License: apache-2.0
- Created: 2017-08-30T23:50:18.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-01T16:23:58.000Z (about 5 years ago)
- Last Synced: 2024-05-22T09:42:58.875Z (6 months ago)
- Language: JavaScript
- Size: 71.3 KB
- Stars: 4,451
- Watchers: 60
- Forks: 118
- Open Issues: 30
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# r2
[![Build Status](https://travis-ci.org/mikeal/r2.svg?branch=master)](https://travis-ci.org/mikeal/r2) [![Coverage Status](https://coveralls.io/repos/github/mikeal/r2/badge.svg?branch=master)](https://coveralls.io/github/mikeal/r2?branch=master) [![Greenkeeper badge](https://badges.greenkeeper.io/mikeal/r2.svg)](https://greenkeeper.io/)
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.```javascript
const r2 = require('r2')let html = await r2('https://www.google.com').text
```Simple JSON support.
```javascript
let obj = {ok: true}let resp = await r2.put('http://localhost/test.json', {json: obj}).json
```Simple headers support.
```javascript
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.