brianleroux / tiny-json-http

:anchor: Minimalist HTTP client for JSON payloads.
172 stars 18 forks source link

tiny-json-http

Minimalist HTTP client for GET, POST, PUT, PATCH and DELETE JSON payloads

npm i tiny-json-http --save

API

Read methods

Write methods

*callback is optional, tiny methods will return a promise if no callback is provided

Options

Callback values

Promises

Examples

With Async / Await

var tiny = require('tiny-json-http')
var url = 'http://www.randomkittengenerator.com'

;(async function _iife() {
  try {
    console.log(await tiny.get({url}))
  } catch (err) {
    console.log('ruh roh!', err)
  }
})();

With Callback

var tiny = require('tiny-json-http')
var url = 'http://www.randomkittengenerator.com'

tiny.get({url}, function _get(err, result) {
  if (err) {
    console.log('ruh roh!', err)
  }
  else {
    console.log(result)
  }
})

Check out the tests for more examples! :heart_decoration: