-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Net | ||
|
||
:::info | ||
|
||
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](./bdapi). | ||
|
||
## Properties | ||
|
||
|
||
|
||
## Methods | ||
|
||
### fetch | ||
Fetches network resources from the server side which avoids CORs. This works similar to [node-fetch](https://github.com/node-fetch/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`](https://developer.mozilla.org/en-US/docs/Web/API/Response) - A custom fetch response that extends the web `Response` with additional `url` and `redirected` properties. | ||
___ |