get-json

Cross-platform library for getting JSON docs

Usage no npm install needed!

<script type="module">
  import getJson from 'https://cdn.skypack.dev/get-json';
</script>

README

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 &mdash; Stolen Car",
    // "Jack White &mdash; Temporary Ground",
    // "I Am Kloot &mdash; Loch",
    // "Portishead &mdash; 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);
    });