Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tiny-json-http

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiny-json-http

Minimalist `HTTP` client for `GET` and `POST`ing `JSON` payloads

  • 5.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
55K
increased by14.38%
Maintainers
1
Weekly downloads
 
Created
Source

tiny-json-http

Minimalist HTTP client for GET and POSTing JSON payloads

  • Zero dependencies: perfect for AWS Lambda or Browserify
  • Sensible default: assumes buffered JSON responses
  • System symmetry: Node style errback API, or Promises for use with Async/Await
npm i tiny-json-http --save

api

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

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

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

promises

  • if no callback is provided to the tiny-json-http methods, a promise is returned
  • perfect for use of async/await

example

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

(async () => {
  try {
    const result = await tiny.get({url})
    console.log(result)
  } 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 __got(err, result) {
  if (err) {
    console.log('ruh roh!', err)
  }
  else {
    console.log(result)
  }
})

Check out the tests for more examples! :heart_decoration:

FAQs

Package last updated on 29 Oct 2017

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