npm.io
1.3.3 • Published 5 years ago

helper-xhr

Licence
ISC
Version
1.3.3
Deps
0
Size
7 kB
Vulns
0
Weekly
0

Helper XHR

Very basic, very simple, xhr promise wrapper. I started using fetch, and soon discovered "replay xhr" is not supported in browsers for fetch request.

So I created this miny/simple/basic xhr request wrapper.

Installation

npm install helper-xhr

There's no dependecy.

Yes it's in ES6.

Usage

import HttpRequest from 'helper-xhr';

var xhr = new HttpRequest("POST", "/foo/bar/", "application/json");
xhr.send({elmer: "fudd"}).then((data) => {
	console.log("got this", data.json);
}).catch((e) => {
	console.log("something wrong", e);
});

console.log("headers", xhr.getAllResponseHeaders());

Contributing

You are welcome!

History

Created on March 22, 2017

Credits

Don't blame me.

License

Do whatever you want with it.

Keywords