vTimeout
Used to set the maximum time for an API request to be resolved and then trigger a function in case it takes longer.
import { vTimeout } from "very-good-fetch";
const abort = new AbortController();
const timeout = new vTimeout({
timeout: 100,
onFailed() {
console.log("🥶 Timeout's over");
abort.abort();
},
});
const response = await timeout.run(async () => {
return await vFetch("/products", {
signal: abort.signal,
});
});