Skip to main content

Function: retry()

retry<T>(cb: () => Awaitable<T>, retries: number): Promise<T>

Asynchronously calls the callback function until it either succeeds or it runs out of retries. For a synchronous variant, see retrySync.

Type parameters

Type parameter
T

Parameters

ParameterTypeDescription
cb() => Awaitable<T>The function to be retried is passed in as a callback function.
retriesnumberThe number of retries is also passed in as a parameter. Minimum of 0.

Returns

Promise<T>

The result of the callback function is returned.

Source

lib/retry.ts:10