JavaScript

Timeouts for fetch & promises

Në shqip: Afati kohor për kërkesat

ShpjegimiSQ

fetch() s'ka afat kohor si parazgjedhje dhe mund të presë përgjithmonë. Me AbortSignal.timeout(5000) e anulon pas 5 sekondash.

EnglishEN

fetch() has no timeout by default and can wait forever. With AbortSignal.timeout(5000) you cancel it after 5 seconds.

Si ta mendosh

Si t'i thuash shoferit „po s'erdhe brenda 5 minutash, iku“.

Lexoje në anglisht

Like telling the driver “if you're not here in 5 minutes, I'm leaving”.

Shembull kodijavascript

const r = await fetch("/api/notat", { signal: AbortSignal.timeout(5000) });

Terma të lidhur