Interview practice question
Adding timeouts to fetch requests
Frontend Engineering · Async JavaScript and the Browser · Intermediate
Some API requests hang for a long time with no response. How do you add timeouts?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- fetch has no built-in timeout.
- AbortSignal.timeout(ms).
- Combine with user cancel (AbortSignal.any).
- Handle TimeoutError distinctly.
- Choose sensible durations.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.