Promise-based XMLHttpRequest
Usage
npm i promise-based-xhr
let request = PromiseBasedXHR({
"method": "GET",
"url": "https://...",
"data": {
"foo": 1,
"bar": 2,
},
"headers": {
"Accept": "application/json, text/javascript, */*; q=0.01",
// ...
},
"params": {
"timeout": 5000,
"ontimeout": function () {
console.error("Timeout");
},
},
});
request
.then((xhr) => {
// Success
})
.catch((xhr) => {
// Failed
})
.finally(() => {
});
Donate
Yandex.Money, Visa, MasterCard, Maestro or click to the "receives" badge.