mirror of
https://github.com/LukeHagar/discoursejs.git
synced 2025-12-09 12:27:49 +00:00
76 lines
4.7 KiB
Markdown
76 lines
4.7 KiB
Markdown
# Site
|
|
(*site*)
|
|
|
|
## Overview
|
|
|
|
### Available Operations
|
|
|
|
* [getSite](#getsite) - Get site info
|
|
|
|
## getSite
|
|
|
|
Can be used to fetch all categories and subcategories
|
|
|
|
### Example Usage
|
|
|
|
```typescript
|
|
import { SDK } from "@lukehagar/discoursejs";
|
|
|
|
const sdk = new SDK();
|
|
|
|
async function run() {
|
|
const result = await sdk.site.getSite();
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Standalone function
|
|
|
|
The standalone function version of this method:
|
|
|
|
```typescript
|
|
import { SDKCore } from "@lukehagar/discoursejs/core.js";
|
|
import { siteGetSite } from "@lukehagar/discoursejs/funcs/siteGetSite.js";
|
|
|
|
// Use `SDKCore` for best tree-shaking performance.
|
|
// You can create one instance of it to use across an application.
|
|
const sdk = new SDKCore();
|
|
|
|
async function run() {
|
|
const res = await siteGetSite(sdk);
|
|
|
|
if (!res.ok) {
|
|
throw res.error;
|
|
}
|
|
|
|
const { value: result } = res;
|
|
|
|
// Handle the result
|
|
console.log(result)
|
|
}
|
|
|
|
run();
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
|
|
### Response
|
|
|
|
**Promise\<[operations.GetSiteResponseBody](../../sdk/models/operations/getsiteresponsebody.md)\>**
|
|
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| --------------- | --------------- | --------------- |
|
|
| errors.SDKError | 4xx-5xx | */* |
|