Skip to content

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.

ParameterTypeOptionalDefaultDescription
urlstringnoneURL to be requested
optionsobject{}Additional options to customize the request
options.method"GET" | "PUT" | "POST" | "DELETE""GET"HTTP method to use for the request.
options.headersRecord<string, string>noneMapping of headers to be sent with the request.
options.redirect"manual" | "follow""follow"Mapping of headers to be sent with the request.
options.maxRedirectsnumber20Maximum number of redirects to be automatically followed.
options.signalAbortSignalnoneSignal to abruptly cancel the request.
options.timeoutnumber3000Maximum number of seconds to wait for the request before timing out.
options.bodyUint8Array | stringnoneSerializable 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.