You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also a timeout isn't the right solution for aborting a fetch request as it will continue to download if you wrap the fetch promise with a timeout race.
The right solution is to use abortcontroller
constcontroller=newAbortController()constsignal=controller.signalsetTimeout(()=>{controller.abort()},1000)fetch(url,{ signal })
FWIW, I've opened an issue whatwg/fetch#951 with a proposal for a timeout option that solves 90% of use cases, in case anyone's interested. I think it's super important to add to make sure calls to fetch (or res.json()) don't hang indefinitely.
Hi guys? There's anyway to set a timeout? (Without use a setTimeout() and throw some error manually)
PS: I'm using react.
Thanks!
The text was updated successfully, but these errors were encountered: