@nelsonomuto/axios-request-timeout
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

axios-request-timeout

wrapper to add timeout to axios request

  • [x] will throw an error when the timeout is passed and the code in the catch block will be executed.

install

yarn add @nelsonomuto/axios-request-timeout

or npm i @nelsonomuto/axios-request-timeout

usage

import axiosRequest from '@nelsonomuto/axios-request-timeout';

try {
  await axiosRequest({
    url: 'https://www.cnn.com/',
    method: 'GET',
    timeout: 10
  });
} catch(error) {
  console.log({ error });
  expect(error).toEqual({'message': 'timeout cancel'});
}

/@nelsonomuto/axios-request-timeout/

    Package Sidebar

    Install

    npm i @nelsonomuto/axios-request-timeout

    Weekly Downloads

    4

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    303 kB

    Total Files

    10

    Last publish

    Collaborators

    • nelsonomuto