xhr-tool

XMLHttpRequest with Promises (in the browser)

Usage no npm install needed!

<script type="module">
  import xhrTool from 'https://cdn.skypack.dev/xhr-tool';
</script>

README

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);
});