Net
TIP
This module is still in beta and is subject to change. This API is mostly finalized, but if fundamental flaws are found during beta, the API may be reworked. Any plan to do so will be announced in Discord.
Net
is a namespace for networking related utility functions. Instance is accessible through the BdApi.
Properties
Methods
fetch
Fetches network resources from the server side which avoids CORs. This works similar to node-fetch.
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
url | string | ❌ | none | URL to be requested |
options | object | ✅ | {} | Additional options to customize the request |
options.method | "GET" | "PUT" | "POST" | "DELETE" | ✅ | "GET" | HTTP method to use for the request. |
options.headers | Record<string, string> | ✅ | none | Mapping of headers to be sent with the request. |
options.redirect | "manual" | "follow" | ✅ | "follow" | Mapping of headers to be sent with the request. |
options.maxRedirects | number | ✅ | 20 | Maximum number of redirects to be automatically followed. |
options.signal | AbortSignal | ✅ | none | Signal to abruptly cancel the request. |
options.timeout | number | ✅ | 3000 | Maximum number of seconds to wait for the request before timing out. |
options.body | Uint8Array | string | ✅ | none | Serializable body data to be sent with the request. |
Returns: Response
- A custom fetch response that extends the web Response
with additional url
and redirected
properties.