Timeout and cancellation

Pass a signal and a deadline to this site’s delayed demo endpoint.

import { Http, envelope } from "fetchzen";
const api = Http.create(`${location.origin}/api/examples/`, {
cache: false, secure: false, preset: envelope,
});
const controller = new AbortController();
// Call controller.abort() from your Cancel control.
try {
console.log(await api.get("delay", {
params: { ms: "1000" }, timeout: 500, signal: controller.signal,
}));
} catch (error) {
console.error(error);
}
Try this requestTimeout / cancellation
Request parameters

Only Run sends a request to this site's demo API. Use synthetic data only; do not send secrets or personal files. Uploads are counted, not stored.

Ready. No request sent.

Result

Choose Run to see the response.
Event log
No events yet.

A 500 ms deadline expires before a 1000 ms response. Increase it or cancel while waiting. The demo bounds delays to 3000 ms. Aborting stops client waiting, not server work already received. Use your own endpoint outside this demo.

Next: retries or safe errors.