import { retry } from "@daiso-tech/core/async";
import { AsyncHooks } from "@daiso-tech/core/utilities";
await new AsyncHooks(async (url: string) => {
const response = await fetch(url);
const json = await response.json();
if (!response.ok) {
throw json
}
return json;
}, retry({ maxAttempts: 8 })).invoke("URL_ENDPOINT");
The
retry
middleware enables automatic retries for all errors or specific errors, with configurable backoff policies. An error will be thrown when all retry attempts fail.IMPORT_PATH:
"@daiso-tech/core/async"