docs: added a note about SC Middleware (#3932)

This commit is contained in:
Shahed Nasser
2023-04-26 20:20:38 +03:00
committed by GitHub
parent 98b8ff8277
commit 3af59e556f

View File

@@ -12,6 +12,12 @@ In this document, you'll learn how to use Publishable API Keys in client request
:::
## Default Behaviour In Product Store Endpoints
If you don't pass a publishable API Key for the store endpoints `/store/products` and `/store/products/{product_id}`, the default sales channel of the store is assigned to the request.
---
## Using Medusa JS Client
When using [Medusas JS Client](../../../js-client/overview.md), you can pass it to the client only once when you create the instance of the client:
@@ -37,6 +43,8 @@ const medusa = new Medusa({
medusa.setPublishableKey(publishableApiKey)
```
---
## Using Medusa React
You can pass the publishable API key to the `MedusaProvider` component:
@@ -58,6 +66,8 @@ const App = () => {
Then, the API key will be passed in the header parameter `x-publishable-api-key` of every request.
---
## Using Other Methods
For other ways of sending requests to your Medusa backend, such as using the Fetch API, you must pass `x-publishable-api-key` in the header of every request. Its value is the publishable API keys `id`.
@@ -75,4 +85,4 @@ fetch(`<BACKEND_URL>/store/products`, {
## See Also
- [Manage publishable keys as an admin](../admin/manage-publishable-api-keys.mdx)
- [Manage publishable keys as an admin](../admin/manage-publishable-api-keys.mdx)