xhr-tool

XMLHttpRequest with Promises (in the browser)


Keywords
xhr, promises, es6
License
LGPL-3.0
Install
npm install xhr-tool@1.0.8

Documentation

xhr-tool

Build Status Dependencies Development Dependencies

Install the package like this:

npm install xhr-tool

Import the function

var getJSON = require('xhr-tool').getJSON;

Needs a browser that supports Promises or a Promise polyfill.

getJSON

getJSON(url) → Promise → Object

Sends an asynchronous request and returns a Promise for the parsed JSON response

Example usage:

getJSON('http://www.nactem.ac.uk/software/acromine/dictionary.py?sf=BMI').then(function(obj) {
    console.log(obj);
});