load-json-xhr

3.0.3 • Public • Published

load-json-xhr

stable

Loads a JSON file from a URI using xhr. The return object is the XMLHttpRequest.

var load = require('load-json-xhr');
 
load('my-file.json', function(err, data) {
    if (err)
        throw err;
    console.log(data.foo.bar);
})

Also accepts an options object which is passed along to the xhr module.

var load = require('load-json-xhr');
 
load({ uri: 'my-file.json', timeout: 5000 }, function(err, data) {
    if (err)
        throw err;
    console.log(data.foo.bar);
})

Usage

NPM

getJSON(opt[, callback])

Gets JSON data from a uri specified in opt. Or you can pass a string.

License

MIT, see LICENSE.md for details.

Package Sidebar

Install

npm i load-json-xhr

Weekly Downloads

8

Version

3.0.3

License

MIT

Last publish

Collaborators

  • bunnybones1