Skip to content

Commit 1414037

Browse files
committed
docs: fix doc errors
1 parent 8d2f41c commit 1414037

File tree

4 files changed

+28
-30
lines changed

4 files changed

+28
-30
lines changed

docs/tutorial/02-getting-started/02-quick-start.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ import { createAlova } from 'alova';
6262
import adapterFetch from 'alova/fetch';
6363

6464
const alovaInstance = createAlova({
65-
requestAdapter: adapterFetch()
65+
requestAdapter: adapterFetch(),
66+
responded: response => response.json()
6667
});
6768
```
6869

@@ -74,7 +75,8 @@ const { createAlova } = require('alova');
7475
const adapterFetch = require('alova/fetch');
7576

7677
const alova = createAlova({
77-
requestAdapter: adapterFetch();
78+
requestAdapter: adapterFetch(),
79+
responded: response => response.json()
7880
});
7981
```
8082

@@ -88,7 +90,8 @@ import { createAlova } from 'npm:alova';
8890
import adapterFetch from 'npm:alova/fetch';
8991

9092
const alova = createAlova({
91-
requestAdapter: adapterFetch();
93+
requestAdapter: adapterFetch(),
94+
responded: response => response.json()
9295
});
9396
```
9497

@@ -100,9 +103,7 @@ requestAdapter: adapterFetch();
100103
Send a request through `alovaInstance.Get`. Since the `adapterFetch` request adapter is used, a `Response` instance will be received. This is very simple.
101104

102105
```js
103-
const response = await alovaInstance
104-
.Get('https://alovajs.dev/user/profile')
105-
.then(response => response.json());
106+
const response = await alovaInstance.Get('https://alovajs.dev/user/profile');
106107
```
107108

108109
In an asynchronous function, you can also use `await alovaInstance.Get` to wait for the response.
@@ -112,13 +113,11 @@ In an asynchronous function, you can also use `await alovaInstance.Get` to wait
112113
Submit data through `alovaInstance.Post`. This is also very simple.
113114

114115
```js
115-
const response = alovaInstance
116-
.Post('https://alovajs.dev/posts', {
117-
title: 'foo',
118-
body: 'bar',
119-
userId: 1
120-
})
121-
.then(response => response.json());
116+
const response = alovaInstance.Post('https://alovajs.dev/posts', {
117+
title: 'foo',
118+
body: 'bar',
119+
userId: 1
120+
});
122121
```
123122

124123
## What to do next?

docs/tutorial/02-getting-started/09-extension-integration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ module.exports = {
8282
*/
8383
handleApi: apiDescriptor => {
8484
// Returning a falsy value means filtering this api
85-
if (!apiDescriptor.path.startWith('/user')) {
85+
if (!apiDescriptor.path.startsWith('/user')) {
8686
return;
8787
}
8888

89-
apiDescriptor.parameter = apiDescriptor.parameter.filter(
89+
apiDescriptor.parameters = (apiDescriptor.parameters || []).filter(
9090
param => param.in === 'header' && param.name === 'token'
9191
);
9292
delete apiDescriptor.requestBody.id;

i18n/zh-CN/docusaurus-plugin-content-docs/current/tutorial/02-getting-started/02-quick-start.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ import { createAlova } from 'alova';
6262
import adapterFetch from 'alova/fetch';
6363

6464
const alovaInstance = createAlova({
65-
requestAdapter: adapterFetch()
65+
requestAdapter: adapterFetch(),
66+
responded: response => response.json()
6667
});
6768
```
6869

@@ -74,7 +75,8 @@ const { createAlova } = require('alova');
7475
const adapterFetch = require('alova/fetch');
7576

7677
const alova = createAlova({
77-
requestAdapter: adapterFetch();
78+
requestAdapter: adapterFetch(),
79+
responded: response => response.json()
7880
});
7981
```
8082

@@ -88,7 +90,8 @@ import { createAlova } from 'npm:alova';
8890
import adapterFetch from 'npm:alova/fetch';
8991

9092
const alova = createAlova({
91-
requestAdapter: adapterFetch();
93+
requestAdapter: adapterFetch(),
94+
responded: response => response.json()
9295
});
9396
```
9497

@@ -100,9 +103,7 @@ const alova = createAlova({
100103
通过 `alovaInstance.Get` 发送一个请求,由于使用了`adapterFetch`请求适配器,将会接收到一个`Response`实例,这很简单。
101104

102105
```js
103-
const response = await alovaInstance
104-
.Get('https://alovajs.dev/user/profile')
105-
.then(response => response.json());
106+
const response = await alovaInstance.Get('https://alovajs.dev/user/profile');
106107
```
107108

108109
在异步函数中,你也可以使用`await alovaInstance.Get`等待响应。
@@ -112,13 +113,11 @@ const response = await alovaInstance
112113
通过 `alovaInstance.Post`提交数据,这同样很简单。
113114

114115
```js
115-
const response = alovaInstance
116-
.Post('https://alovajs.dev/posts', {
117-
title: 'foo',
118-
body: 'bar',
119-
userId: 1
120-
})
121-
.then(response => response.json());
116+
const response = alovaInstance.Post('https://alovajs.dev/posts', {
117+
title: 'foo',
118+
body: 'bar',
119+
userId: 1
120+
});
122121
```
123122

124123
## 接下来要做什么?

i18n/zh-CN/docusaurus-plugin-content-docs/current/tutorial/02-getting-started/09-extension-integration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ module.exports = {
8080
*/
8181
handleApi: apiDescriptor => {
8282
// 返回falsy值表示过滤此api
83-
if (!apiDescriptor.path.startWith('/user')) {
83+
if (!apiDescriptor.path.startsWith('/user')) {
8484
return;
8585
}
8686

87-
apiDescriptor.parameter = apiDescriptor.parameter.filter(
87+
apiDescriptor.parameters = (apiDescriptor.parameters || []).filter(
8888
param => param.in === 'header' && param.name === 'token'
8989
);
9090
delete apiDescriptor.requestBody.id;

0 commit comments

Comments
 (0)