New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

fetchout

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetchout

fetch with a timeout

latest
Source
npmnpm
Version
2.0.1
Version published
Maintainers
1
Created
Source

fetchout - fetch with a timeout

Add request timeouts to fetch() calls.

Install

$ npm install fetchout

Usage

const fetchout = require('fetchout');

// Default timeout for all requests. If not set the default is 60 seconds.
fetchout.defaultTimeout(5000);


(async function() {

    try {
        // default timeout of 5 seconds used
        let response1 = await fetchout('http://httpbin.org/delay/3');
        console.log(`response1 status ${response1.status}`)

        // Set a 7 sec timeout for a GET fetch request
        let response2 = await fetchout('http://httpbin.org/delay/3', 7000);
        console.log(`response2 status ${response2.status}`)

        // Set a 6 sec timeout for a POST fetch request - timeout error
        let response3 = await fetchout('http://httpbin.org/delay/9',
           { method: 'POST', body: '{"foo": "bar"}' }, 6000);
    }
    catch (err) {
        console.log(`${err}`);
    }

})();

License

Apache 2.0 license; see LICENSE.

Keywords

fetch

FAQs

Package last updated on 17 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts