docs: added credentials option to fetch examples (#2694)

This commit is contained in:
Shahed Nasser
2022-11-29 17:21:19 +02:00
committed by GitHub
parent a917b0a109
commit 657ada6fb0
8 changed files with 88 additions and 24 deletions
@@ -274,6 +274,7 @@ medusa.admin.batchJobs.create({
```jsx
fetch(`<YOUR_SERVER>/admin/batch-jobs`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
@@ -328,7 +329,9 @@ medusa.admin.batchJobs.retrieve(batchJobId)
<TabItem value="fetch" label="Fetch API">
```jsx
fetch(`<YOUR_SERVER>/admin/batch-jobs/${batchJobId}`)
fetch(`<YOUR_SERVER>/admin/batch-jobs/${batchJobId}`, {
credentials: 'include',
})
.then((response) => response.json())
.then(({ batch_job }) => {
console.log(batch_job.status, batch_job.result);
@@ -382,7 +385,8 @@ medusa.admin.batchJobs.confirm(batchJobId)
```jsx
fetch(`<YOUR_SERVER>/admin/batch-jobs/${batchJobId}/confirm`, {
method: 'POST'
method: 'POST',
credentials: 'include',
})
.then((response) => response.json())
.then(({ batch_job }) => {
@@ -100,6 +100,7 @@ medusa.admin.priceLists.create({
```jsx
fetch(`<SERVER_URL>/admin/price-lists`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
@@ -186,7 +187,9 @@ medusa.admin.priceLists.retrieve(priceListId)
<TabItem value="fetch" label="Fetch API">
```jsx
fetch(`<SERVER_URL>/admin/price-lists/${priceListId}`)
fetch(`<SERVER_URL>/admin/price-lists/${priceListId}`, {
credentials: 'include',
})
.then((response) => response.json())
.then(({ price_list }) => {
console.log(price_list.id)
@@ -230,6 +233,7 @@ medusa.admin.priceLists.update(priceListId, {
```jsx
fetch(`<SERVER_URL>/admin/price-lists/${priceListId}`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
@@ -298,6 +302,7 @@ medusa.admin.priceLists.addPrices(priceListId, {
```jsx
fetch(`<SERVER_URL>/admin/price-lists/${priceListId}/prices/batch`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
@@ -361,7 +366,8 @@ medusa.admin.priceLists.deleteProductPrices(priceListId, productId)
```jsx
fetch(`<SERVER_URL>/admin/price-lists/${priceListId}/products/${productId}/prices`, {
method: 'DELETE'
method: 'DELETE',
credentials: 'include',
})
.then((response) => response.json())
.then(({ ids, object, deleted }) => {
@@ -401,7 +407,8 @@ medusa.admin.priceLists.deleteVariantPrices(priceListId, variantId)
```jsx
fetch(`<SERVER_URL>/admin/price-lists/${priceListId}/variants/${variantId}/prices`, {
method: 'DELETE'
method: 'DELETE',
credentials: 'include',
})
.then((response) => response.json())
.then(({ ids, object, deleted }) => {
@@ -443,7 +450,8 @@ medusa.admin.priceLists.delete(priceListId)
```jsx
fetch(`<SERVER_URL>/admin/price-lists/${priceListId}`, {
method: 'DELETE'
method: 'DELETE',
credentials: 'include',
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
@@ -71,6 +71,7 @@ medusa.admin.salesChannels.create({
```jsx
fetch(`<SERVER_URL>/admin/sales-channels`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
@@ -125,7 +126,9 @@ medusa.admin.salesChannels.list()
<TabItem value="fetch" label="Fetch API">
```jsx
fetch(`<SERVER_URL>/admin/sales-channels`)
fetch(`<SERVER_URL>/admin/sales-channels`, {
credentials: 'include',
})
.then((response) => response.json())
.then(({ sales_channels, limit, offset, count }) => {
console.log(sales_channels.length)
@@ -165,7 +168,9 @@ medusa.admin.salesChannels.retrieve(salesChannelId)
<TabItem value="fetch" label="Fetch API">
```jsx
fetch(`<SERVER_URL>/admin/sales-channels/${salesChannelId}`)
fetch(`<SERVER_URL>/admin/sales-channels/${salesChannelId}`, {
credentials: 'include',
})
.then((response) => response.json())
.then(({ sales_channels, limit, offset, count }) => {
console.log(sales_channels.length)
@@ -209,6 +214,7 @@ medusa.admin.salesChannels.update(salesChannelId, {
```jsx
fetch(`<SERVER_URL>/admin/sales-channels/${salesChannelId}`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
@@ -264,7 +270,8 @@ medusa.admin.salesChannels.delete(salesChannelId)
```jsx
fetch(`<SERVER_URL>/admin/sales-channels/${salesChannelId}`, {
method: 'DELETE'
method: 'DELETE',
credentials: 'include',
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
@@ -315,6 +322,7 @@ medusa.admin.salesChannels.addProducts(salesChannelId, {
```jsx
fetch(`<SERVER_URL>/admin/sales-channels/${salesChannelId}/products/batch`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
@@ -377,7 +385,9 @@ medusa.admin.products.list({
<TabItem value="fetch" label="Fetch API">
```jsx
fetch(`<SERVER_URL>/admin/products?sales_channel_id[0]=${salesChannelId}`)
fetch(`<SERVER_URL>/admin/products?sales_channel_id[0]=${salesChannelId}`, {
credentials: 'include',
})
.then((response) => response.json())
.then(({ products, limit, offset, count }) => {
console.log(products.length)
@@ -429,6 +439,7 @@ medusa.admin.salesChannels.removeProducts(salesChannelId, {
```jsx
fetch(`<SERVER_URL>/admin/sales-channels/${salesChannelId}/products/batch`, {
method: 'DELETE',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
@@ -495,7 +506,9 @@ medusa.admin.orders.list({
<TabItem value="fetch" label="Fetch API">
```jsx
fetch(`<SERVER_URL>/admin/orders?sales_channel_id[0]=${salesChannelId}`)
fetch(`<SERVER_URL>/admin/orders?sales_channel_id[0]=${salesChannelId}`, {
credentials: 'include',
})
.then((response) => response.json())
.then(({ orders, limit, offset, count }) => {
console.log(orders.length)