Returns a promise that rejects with a TimeoutError after a specified delay.
TimeoutError
The delay duration in milliseconds.
A promise that rejects with a TimeoutError after the specified delay.
Throws a TimeoutError after the specified delay.
try { await timeout(1000); // Timeout exception after 1 second} catch (error) { console.error(error); // Will log 'The operation was timed out'} Copy
try { await timeout(1000); // Timeout exception after 1 second} catch (error) { console.error(error); // Will log 'The operation was timed out'}
Alias