get-json

1.1.0 • Public • Published

get-json

Cross-platform library for getting JSON documents. Wraps request on Node, fallsback to JSONP on browsers.

$ npm install get-json

Usage

var getJSON = require('get-json')

getJSON('http://api.listenparadise.org', function(error, response){

    console.log(error);
    // undefined

    console.log(response);
    // ["Beth Orton — Stolen Car",
    // "Jack White — Temporary Ground",
    // "I Am Kloot — Loch",
    // "Portishead — Glory Box"]
});

Alternatively, you can use a Promise:

var getJSON = require('get-json')

getJSON('http://api.listenparadise.org')
    .then(function(response) {
      console.log(response);
    }).catch(function(error) {
      console.log(error);
    });

Readme

Keywords

Package Sidebar

Install

npm i get-json

Weekly Downloads

17,651

Version

1.1.0

License

BSD-3-Clause

Unpacked Size

12.9 kB

Total Files

9

Last publish

Collaborators

  • zeke
  • ljharb