promise-based-xhr

1.0.2 • Public • Published

GitHub license Donate to liberapay

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.

Package Sidebar

Install

npm i promise-based-xhr

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

4.21 kB

Total Files

6

Last publish

Collaborators

  • don.bidon