docs: added credentials option to fetch examples (#2694)
This commit is contained in:
@@ -79,6 +79,7 @@ formData.append('files', file); //file is an instance of File
|
||||
|
||||
fetch(`<YOUR_SERVER>/admin/uploads`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
@@ -134,6 +135,7 @@ medusa.admin.batchJobs.create({
|
||||
```jsx
|
||||
fetch(`<YOUR_SERVER>/admin/batch-jobs`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
@@ -210,7 +212,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);
|
||||
@@ -270,7 +274,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 }) => {
|
||||
|
||||
@@ -73,6 +73,7 @@ formData.append('files', file); //file is an instance of File
|
||||
|
||||
fetch(`<YOUR_SERVER>/admin/uploads`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
@@ -127,6 +128,7 @@ medusa.admin.batchJobs.create({
|
||||
```jsx
|
||||
fetch(`<YOUR_SERVER>/admin/batch-jobs`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
@@ -198,7 +200,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);
|
||||
@@ -258,7 +262,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 }) => {
|
||||
|
||||
@@ -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'
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user