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
@@ -57,6 +57,7 @@ medusa.admin.customerGroups.create({
```jsx
fetch(`<SERVER_URL>/admin/customer-groups`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
@@ -107,7 +108,9 @@ medusa.admin.customerGroups.list()
<TabItem value="fetch" label="Fetch API">
```jsx
fetch(`<SERVER_URL>/admin/customer-groups`)
fetch(`<SERVER_URL>/admin/customer-groups`, {
credentials: 'include',
})
.then((response) => response.json())
.then(({ customer_groups, limit, offset, count }) => {
console.log(customer_groups.length)
@@ -149,7 +152,9 @@ medusa.admin.customerGroups.retrieve(customerGroupId)
<TabItem value="fetch" label="Fetch API">
```jsx
fetch(`<SERVER_URL>/admin/customer-groups/${customerGroupId}`)
fetch(`<SERVER_URL>/admin/customer-groups/${customerGroupId}`, {
credentials: 'include',
})
.then((response) => response.json())
.then(({ customer_group }) => {
console.log(customer_group.id)
@@ -195,6 +200,7 @@ medusa.admin.customerGroups.update(customerGroupId, {
```jsx
fetch(`<SERVER_URL>/admin/customer-groups/${customerGroupId}`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
@@ -250,7 +256,8 @@ medusa.admin.customerGroups.delete(customerGroupId)
```jsx
fetch(`<SERVER_URL>/admin/customer-groups/${customerGroupId}`, {
method: 'DELETE'
method: 'DELETE',
credentials: 'include',
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
@@ -301,6 +308,7 @@ medusa.admin.customerGroups.addCustomers(customerGroupId, {
```jsx
fetch(`<SERVER_URL>/admin/customer-groups/${customerGroupId}/customers/batch`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
@@ -357,7 +365,9 @@ medusa.admin.customerGroups.listCustomers(customerGroupId)
<TabItem value="fetch" label="Fetch API">
```jsx
fetch(`<SERVER_URL>/admin/customer-groups/${customerGroupId}/customers`)
fetch(`<SERVER_URL>/admin/customer-groups/${customerGroupId}/customers`, {
credentials: 'include',
})
.then((response) => response.json())
.then(({ customers, count, offset, limit }) => {
console.log(customers.length)
@@ -409,6 +419,7 @@ medusa.admin.customerGroups.removeCustomers(customer_group_id, {
```jsx
fetch(`<SERVER_URL>/admin/customer-groups/${customerGroupId}/customers/batch`, {
method: 'DELETE',
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},