Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including promise-xhr with all npm packages installed. Try it out:

var promiseXhr = require("promise-xhr")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

promise-xhr v1.0.1

Wrapper for the XHR package

Promise XHR (xdr)

This is a Promise XHR wrapper. Uses under the hood.


For older browsers you need a promise polyfill.


#xA0;npm i --save promise-xhr


const xhr = require('promise-xhr');
const api = '';

// Options available:
const options = {};

// Basic get request
    .then(res => console.log(res))
    .catch(err => console.error(err));

// With options
xhr(api, {
    method: 'POST',
    useXDR: true
    .then(res => console.log(res)
    .catch(err => console.error(err));

// Available methods: get, post, put, patch, del, head
xhr.get(api).then(console.log).catch(console.error);, options).then(console.log).catch(console.error);

XHR package docs


Contributions are appreciated.


MIT-licensed. See LICENSE.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free