Skip to content

Commit

Permalink
Add net beta docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zerebos committed Nov 1, 2023
1 parent 6b3904f commit a6ba3a3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/api/bdapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ An instance of [Data](./data) to manage data.
**Type:** `Data`
___

### Net
An instance of [Net](./net) for networking requests.

**Type:** `Net`
___

### Patcher
An instance of [Patcher](./patcher) to monkey patch functions.

Expand Down
34 changes: 34 additions & 0 deletions docs/api/net.md
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>|&#x2705;|*none*|Mapping of headers to be sent with the request.
options.redirect|"manual" \| "follow"|&#x2705;|"follow"|Mapping of headers to be sent with the request.
options.maxRedirects|number|&#x2705;|20|Maximum number of redirects to be automatically followed.
options.signal|AbortSignal|&#x2705;|*none*|Signal to abruptly cancel the request.
options.timeout|number|&#x2705;|3000|Maximum number of seconds to wait for the request before timing out.
options.body|Uint8Array \| string|&#x2705;|*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.
___

0 comments on commit a6ba3a3

Please sign in to comment.