Skip to content

Minimalist HTTP client for GET and POSTing JSON payloads

Notifications You must be signed in to change notification settings

Patafix/tiny-json-http

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tiny-json-http

Minimalist HTTP client for GET and POSTing JSON payloads

  • Zero dependencies: perfect for AWS Lambda or Browserify
  • Sane default: assumes buffered JSON responses
  • System symmetry: Node style errback API
npm i tiny-json-http --save

api

  • tiny.get(options, callback)
  • tiny.post(options, callback)
  • tiny.put(options, callback)
  • tiny.del(options, callback)

options

  • url required
  • data form vars for tiny.post, tiny.put, and tiny.delete otherwise querystring vars for tiny.get
  • headers key/value map used for headers

callback values

  • err a real javascript Error if there was one
  • data an object with headers and body keys

example

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

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

Check out the tests for more examples! 💟

About

Minimalist HTTP client for GET and POSTing JSON payloads

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%