Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including idiot with all npm packages installed. Try it out:

var idiot = require("idiot")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

idiot v2.0.1

Simple JSON REST client

idiot

A simple JSON REST client

  • Lightweight for the browser and Node.js
  • Supports Promises and callbacks

Build Status

Install

npm install --save idiot

Usage

const client = require('idiot')({
  baseUrl: 'http://localhost:8080/api'
});

return client.get('/movies').then(data => {
  // got a 2xx response from http://localhost:8080/api/movies
});

Documentation

new Idiot( options )

  • options {Object}
    • baseUrl {String} (required) each request url is formed by appending the uri to this value
    • Promise {Function} (optional) specify your own Promise library

client.delete( uri, [query], [cb] )

  • uri {String}
  • query {Object} (optional) querystring values
  • cb {Function} (optional) callback

client.get( uri, [query], [cb] )

  • uri {String}
  • query {Object} (optional) querystring values
  • cb {Function} (optional) callback

client.patch( uri, body, [query], [cb] )

  • uri {String}
  • body {Object}
  • query {Object} (optional) querystring values
  • cb {Function} (optional) callback

client.post( uri, body, [query], [cb] )

  • uri {String}
  • body {Object}
  • query {Object} (optional) querystring values
  • cb {Function} (optional) callback

client.put( uri, body, [query], [cb] )

  • uri {String}
  • body {Object}
  • query {Object} (optional) querystring values
  • cb {Function} (optional) callback

client.request( options, [cb] )

  • options
    • method
    • uri
    • body
    • query
    • aborter
  • cb (optional)
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free