From a6ba3a369c7149bdce099eca1df6330cc09ac472 Mon Sep 17 00:00:00 2001 From: Zack Rauen Date: Wed, 1 Nov 2023 14:44:15 -0400 Subject: [PATCH] Add net beta docs --- docs/api/bdapi.md | 6 ++++++ docs/api/net.md | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 docs/api/net.md diff --git a/docs/api/bdapi.md b/docs/api/bdapi.md index 6e04421..130135a 100644 --- a/docs/api/bdapi.md +++ b/docs/api/bdapi.md @@ -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. diff --git a/docs/api/net.md b/docs/api/net.md new file mode 100644 index 0000000..a3179f9 --- /dev/null +++ b/docs/api/net.md @@ -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|✅|*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. +___