Open justfede opened 6 years ago
Nada?
possible duplicate of #48? so can this be closed?
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
const controller = new AbortController()
const signal = controller.signal
setTimeout(() => {
controller.abort()
}, 1000)
fetch(url, { signal })
FWIW, I've opened an issue https://github.com/whatwg/fetch/issues/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!