Skip to main content

Introduction

caution

This library is only compatible with Node.js v18+ and relies on the native Fetch API which is an experimental feature.

Getting Started

  1. Install Reliable Fetch using your favorite package manager.
npm add --save-dev @hachibu/reliable-fetch
  1. Create a file named timeout.js with the following code.
const reliableFetch = require('@hachibu/reliable-fetch').default

async function main() {
const timeout = 10 // milliseconds

await reliableFetch('https://google.com')
.on('timeout', () => console.log('timeout triggered'))
.timeout({ timeout })
.catch(console.log)
}

main()
  1. Finally, run the code.
node timeout.ts