-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added timeout support #435
Conversation
Thanks, but we can't accept a feature that's not in the spec! See https://github.com/github/fetch#read-this-first and #175 (comment) #405 #246 #181 #68 #16 for background. |
ok, got it. |
Excuse me, how could we increase timeout to Infinity or over 120s which is default value of Chrome? I couldn't find out a solution from those issues :/ Do I have to switch to axios or other libs to do the fetch? |
@fritx
|
@Gcaufy your code looks like to declare a timeout instead, but I want to drop any timeout that would exist. Am I missing something? |
this is like
so I guess what you need is
or a common call back, like:
what ever you need, you can use Promise.race get what you want:
|
actually, this is what you should be doing: const controller = new AbortController()
const signal = controller.signal
setTimeout(() => {
controller.abort()
}, 1000)
fetch(url, { signal }) |
it's really useful to add a timeout option.