Skip to content
Get JSON docs on both Node and Browsers
JavaScript
Branch: master
Clone or download
Pull request Compare This branch is 20 commits ahead, 1 commit behind azer:master.
Latest commit 51d4779 Oct 7, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
.gitignore
.npmignore
.travis.yml
README.md
index.js
package.json
test.js

README.md

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);
    });
You can’t perform that action at this time.