1.0.4 • Published 5 years ago

@nelsonomuto/axios-request-timeout v1.0.4

Weekly downloads
23
License
MIT
Repository
github
Last release
5 years ago

axios-request-timeout

wrapper to add timeout to axios request

  • 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'});
}