docs: generate + configure js sdk reference (#9714)

Manually generate the JS SDK reference + add it to the sidebar
This commit is contained in:
Shahed Nasser
2024-10-22 17:31:32 +00:00
committed by GitHub
parent af3c6b0d93
commit a1190b7208
476 changed files with 76450 additions and 189 deletions
@@ -0,0 +1,27 @@
import { TypeList } from "docs-ui"
# batchCustomers
This method manages customers of a group to add or remove them from the group.
It sends a request to the [Manage Customers](https://docs.medusajs.com/v2/api/admin#customer-groups\_postcustomergroupsidcustomers)
API route.
## Example
```ts
sdk.admin.customerGroup.batchCustomers("cusgroup_123", {
add: ["cus_123"],
remove: ["cus_321"]
})
.then(({ customer_group }) => {
console.log(customer_group)
})
```
## Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The group's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"body","type":"[AdminBatchLink](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminBatchLink/page.mdx)","description":"The customers to add or remove from the group.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"add","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"remove","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="batchCustomers"/>
## Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[AdminCustomerGroupResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCustomerGroupResponse/page.mdx)&#62;","optional":false,"defaultValue":"","description":"The customer group's details.","expandable":false,"children":[{"name":"AdminCustomerGroupResponse","type":"[AdminCustomerGroupResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCustomerGroupResponse/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"customer_group","type":"[AdminCustomerGroup](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCustomerGroup/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"customers","type":"`AdminCustomer`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="batchCustomers"/>
@@ -0,0 +1,26 @@
import { TypeList } from "docs-ui"
# create
This method creates a customer group. It sends a request to the
[Create Customer Group](https://docs.medusajs.com/v2/api/admin#customer-groups\_postcustomergroups)
API route.
## Example
```ts
sdk.admin.customerGroup.create({
name: "VIP"
})
.then(({ customer_group }) => {
console.log(customer_group)
})
```
## Parameters
<TypeList types={[{"name":"body","type":"[AdminCreateCustomerGroup](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCreateCustomerGroup/page.mdx)","description":"The customer group's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"query","type":"[AdminGetCustomerGroupParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminGetCustomerGroupParams/page.mdx)","description":"Configure the fields to retrieve in the customer group.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="create"/>
## Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[AdminCustomerGroupResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCustomerGroupResponse/page.mdx)&#62;","optional":false,"defaultValue":"","description":"The customer group's details.","expandable":false,"children":[{"name":"AdminCustomerGroupResponse","type":"[AdminCustomerGroupResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCustomerGroupResponse/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"customer_group","type":"[AdminCustomerGroup](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCustomerGroup/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"customers","type":"`AdminCustomer`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="create"/>
@@ -0,0 +1,24 @@
import { TypeList } from "docs-ui"
# delete
This method deletes a customer group. This method sends a request to the
[Delete Customer Group](https://docs.medusajs.com/v2/api/admin#customer-groups\_deletecustomergroupsid)
API route.
## Example
```ts
sdk.admin.customerGroup.delete("cusgroup_123")
.then(({ deleted }) => {
console.log(deleted)
})
```
## Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The customer group's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="delete"/>
## Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;AdminCustomerGroupDeleteResponse&#62;","optional":false,"defaultValue":"","description":"The deletion's details.","expandable":false,"children":[{"name":"AdminCustomerGroupDeleteResponse","type":"`AdminCustomerGroupDeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="delete"/>
File diff suppressed because one or more lines are too long
@@ -0,0 +1,38 @@
import { TypeList } from "docs-ui"
# retrieve
This method retrieves a customer group by its ID. It sends a request to the
[Get Customer Group](https://docs.medusajs.com/v2/api/admin#customer-groups\_getcustomergroupsid) API route.
## Example
To retrieve a customer group by its ID:
```ts
sdk.admin.customerGroup.retrieve("cusgroup_123")
.then(({ customer_group }) => {
console.log(customer_group)
})
```
To specify the fields and relations to retrieve:
```ts
sdk.admin.customerGroup.retrieve("cusgroup_123", {
fields: "id,*customer"
})
.then(({ customer_group }) => {
console.log(customer_group)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
## Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The customer group's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[AdminGetCustomerGroupParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminGetCustomerGroupParams/page.mdx)","description":"Configure the fields to retrieve in the customer group.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="retrieve"/>
## Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[AdminCustomerGroupResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCustomerGroupResponse/page.mdx)&#62;","optional":false,"defaultValue":"","description":"The group's details.","expandable":false,"children":[{"name":"AdminCustomerGroupResponse","type":"[AdminCustomerGroupResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCustomerGroupResponse/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"customer_group","type":"[AdminCustomerGroup](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCustomerGroup/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"customers","type":"`AdminCustomer`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="retrieve"/>
@@ -0,0 +1,26 @@
import { TypeList } from "docs-ui"
# update
This method updates a customer group's details. It sends a request to the
[Update Customer](https://docs.medusajs.com/v2/api/admin#customer-groups\_postcustomergroupsid)
API route.
## Example
```ts
sdk.admin.customerGroup.update("cusgroup_123", {
name: "VIP"
})
.then(({ customer_group }) => {
console.log(customer_group)
})
```
## Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The customer group's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"body","type":"[AdminUpdateCustomerGroup](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminUpdateCustomerGroup/page.mdx)","description":"The details to update in the group.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"query","type":"[AdminGetCustomerGroupParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminGetCustomerGroupParams/page.mdx)","description":"Configure the fields to retrieve in the customer group.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="update"/>
## Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[AdminCustomerGroupResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCustomerGroupResponse/page.mdx)&#62;","optional":false,"defaultValue":"","description":"The customer group's details.","expandable":false,"children":[{"name":"AdminCustomerGroupResponse","type":"[AdminCustomerGroupResponse](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCustomerGroupResponse/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"customer_group","type":"[AdminCustomerGroup](../../../../../types/HttpTypes/interfaces/types.HttpTypes.AdminCustomerGroup/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"customers","type":"`AdminCustomer`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="update"/>
@@ -0,0 +1,223 @@
import { TypeList } from "docs-ui"
# client
## baseUrl
___
## globalHeaders
### tags
Tags to cache data under for Next.js applications.
Learn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).
___
## publishableKey
___
## apiKey
___
## auth
### type
### jwtTokenStorageKey
### jwtTokenStorageMethod
### type
### jwtTokenStorageKey
### jwtTokenStorageMethod
___
## logger
### error
#### Parameters
<TypeList types={[{"name":"messages","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
#### Returns
<TypeList types={[{"name":"void","type":"`void`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### warn
#### Parameters
<TypeList types={[{"name":"messages","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
#### Returns
<TypeList types={[{"name":"void","type":"`void`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### info
#### Parameters
<TypeList types={[{"name":"messages","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
#### Returns
<TypeList types={[{"name":"void","type":"`void`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### debug
#### Parameters
<TypeList types={[{"name":"messages","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
#### Returns
<TypeList types={[{"name":"void","type":"`void`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## debug
## error
### Parameters
<TypeList types={[{"name":"messages","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"void","type":"`void`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## warn
### Parameters
<TypeList types={[{"name":"messages","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"void","type":"`void`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## info
### Parameters
<TypeList types={[{"name":"messages","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"void","type":"`void`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## debug
### Parameters
<TypeList types={[{"name":"messages","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"void","type":"`void`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
## constructor
### Parameters
<TypeList types={[{"name":"config","type":"[Config](../../../types/js_sdk.admin.Config/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"baseUrl","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"globalHeaders","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"publishableKey","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"apiKey","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"auth","type":"`object`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"type","type":"`\"jwt\"` \\| `\"session\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"jwtTokenStorageKey","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"jwtTokenStorageMethod","type":"`\"local\"` \\| `\"session\"` \\| `\"memory\"` \\| `\"nostore\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"logger","type":"[Logger](../../../types/js_sdk.admin.Logger/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"error","type":"(...`messages`: `string`[]) => `void`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"warn","type":"(...`messages`: `string`[]) => `void`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"info","type":"(...`messages`: `string`[]) => `void`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"debug","type":"(...`messages`: `string`[]) => `void`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"debug","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="new Client"/>
___
`fetch` closely follows (and uses under the hood) the native `fetch` API. There are, however, few key differences:
- Non 2xx statuses throw a `FetchError` with the status code as the `status` property, rather than resolving the promise
- You can pass `body` and `query` as objects, and they will be encoded and stringified.
- The response gets parsed as JSON if the `accept` header is set to `application/json`, otherwise the raw Response object is returned
Since the response is dynamically determined, we cannot know if it is JSON or not. Therefore, it is important to pass `Response` as the return type
## Type Parameters
<TypeList types={[{"name":"T","type":"`unknown`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="fetch"/>
## Parameters
<TypeList types={[{"name":"input","type":"`string` \\| `URL` \\| `Request`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"init","type":"[FetchArgs](../../../types/js_sdk.admin.FetchArgs/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"query","type":"`Record<string, any>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"body","type":"`RequestInit`[`\"body\"`] \\| `Record<string, any>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="fetch"/>
## Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;T&#62;","optional":false,"defaultValue":"","description":"Promise&#60;T&#62;","expandable":false,"children":[{"name":"T","type":"T","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="fetch"/>
`fetchStream` is a helper method to deal with server-sent events. It returns an object with a stream and an abort function.
It follows a very similar interface to `fetch`, with the return value being an async generator.
The stream is an async generator that yields `ServerSentEventMessage` objects, which contains the event name, stringified data, and few other properties.
The caller is responsible for handling `disconnect` events and aborting the stream. The caller is also responsible for parsing the data field.
## Parameters
<TypeList types={[{"name":"input","type":"`string` \\| `URL` \\| `Request`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"init","type":"[FetchArgs](../../../types/js_sdk.admin.FetchArgs/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"query","type":"`Record<string, any>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../types/js_sdk.admin.ClientHeaders/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"body","type":"`RequestInit`[`\"body\"`] \\| `Record<string, any>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="fetchStream"/>
## Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[FetchStreamResponse](../../../interfaces/js_sdk.admin.FetchStreamResponse/page.mdx)&#62;","optional":false,"defaultValue":"","description":"FetchStreamResponse","expandable":false,"children":[{"name":"FetchStreamResponse","type":"[FetchStreamResponse](../../../interfaces/js_sdk.admin.FetchStreamResponse/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"stream","type":"`null` \\| AsyncGenerator&#60;[ServerSentEventMessage](../../../interfaces/js_sdk.admin.ServerSentEventMessage/page.mdx), void, unknown&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"comment","type":"`string`","description":"Ignored by the client.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"event","type":"`string`","description":"A string identifying the type of event described.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`string`","description":"The data field for the message. Split by new lines.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `number`","description":"The event ID to set the EventSource object's last event ID value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"retry","type":"`number`","description":"The reconnection time.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"abort","type":"() => `void`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="fetchStream"/>
## Parameters
<TypeList types={[{"name":"token","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="setToken"/>
## Returns
<TypeList types={[{"name":"void","type":"`void`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="setToken"/>
## Returns
<TypeList types={[{"name":"void","type":"`void`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="clearToken"/>
## Returns
<TypeList types={[{"name":"void","type":"`void`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="clearToken_"/>
## Returns
<TypeList types={[{"name":"ClientFetch","type":"(`input`: [FetchInput](../../../types/js_sdk.admin.FetchInput/page.mdx), `init?`: [FetchArgs](../../../types/js_sdk.admin.FetchArgs/page.mdx)) => Promise&#60;Response&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="initClient"/>
## Returns
<TypeList types={[{"name":"object \\| object","type":"`object` \\| `object`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="getApiKeyHeader_"/>
## Returns
<TypeList types={[{"name":"object \\| object","type":"`object` \\| `object`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="getPublishableKeyHeader_"/>
## Returns
<TypeList types={[{"name":"object \\| object","type":"`object` \\| `object`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="getJwtHeader_"/>
## Parameters
<TypeList types={[{"name":"token","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="setToken_"/>
## Returns
<TypeList types={[{"name":"void","type":"`void`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="setToken_"/>
## Returns
<TypeList types={[{"name":"undefined \\| null \\| string","type":"`undefined` \\| `null` \\| `string`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="getToken_"/>
## Returns
<TypeList types={[{"name":"storageMethod","type":"`\"session\"` \\| `\"local\"` \\| `\"memory\"` \\| `\"nostore\"`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"storageKey","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="getTokenStorageInfo_"/>
<TypeList types={[{"name":"storageMethod","type":"`\"session\"` \\| `\"local\"` \\| `\"memory\"` \\| `\"nostore\"`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"storageKey","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="getTokenStorageInfo_"/>