fetchWithTimeout
Sends a fetch request to a specified URL with a timeout. If the request does not complete within the specified timeout, it is aborted.
Parameters
| Parameter | Type | Optional | Default | Description |
|---|---|---|---|---|
| url | RequestInfo | false | A string representing the URL for fetching. | |
| options | RequestInit | true | { } | Options for the HTTP(S) request. |
| timeout | number | true | 5000 | Time measured in milliseconds. |
Returns
Example
fetchWithTimeout("https://google.com/", {}, 2000); // Promise<Response>