Example
Copy
import { run } from "trybox";
const r = await run(() => fetch("/api/items").then((x) => x.json()), {
retries: 3,
retryDelay: (attempt) => attempt * 200,
timeout: 2000,
onError: (error) => console.error("Request failed:", error),
});
if (r.ok) {
console.log("Data received:", r.data);
} else {
console.error("Error code:", r.error.code);
}