promise timeouts
npm install @amphibian/promise-timeout
import timeout from '@amphibian/promise-timeout';
async function getUsers() {
const response = await timeout(fetch('https://reqres.in/api/users'));
const user = await response.json();
return user;
}const request = fetch('https://reqres.in/api/users')
.then((response) => response.json());
timeout(request, {timeout: 2000});The function to timeout. Should return a Promise or be async.
Default: 500
Number of milliseconds to wait before throwing an error.