Skip to content

Commit

Permalink
docs: correct fetchAdapter to adapterFetch
Browse files Browse the repository at this point in the history
  • Loading branch information
JOU-amjs committed Sep 18, 2024
1 parent 00266a5 commit 9179c97
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
16 changes: 8 additions & 8 deletions docs/tutorial/02-getting-started/02-quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ In alova, you need to initiate a request through an alova instance. Let's create

```javascript
import { createAlova } from 'alova';
import fetchAdapter from 'alova/fetch';
import adapterFetch from 'alova/fetch';

const alovaInstance = createAlova({
requestAdapter: fetchAdapter()
requestAdapter: adapterFetch()
});
```

Expand All @@ -71,24 +71,24 @@ const alovaInstance = createAlova({

```javascript
const { createAlova } = require('alova');
const fetchAdapter = require('alova/fetch');
const adapterFetch = require('alova/fetch');

const alova = createAlova({
requestAdapter: fetchAdapter();
requestAdapter: adapterFetch();
});
```

> When using fetchAdapter in nodejs, the nodejs version requires `v17.5`, or you can use [axios request adapter](/resource/request-adapter/axios/).
> When using adapterFetch in nodejs, the nodejs version requires `v17.5`, or you can use [axios request adapter](/resource/request-adapter/axios/).
</TabItem>
<TabItem value="3" label="deno">

```javascript
import { createAlova } from 'npm:alova';
import fetchAdapter from 'npm:alova/fetch';
import adapterFetch from 'npm:alova/fetch';

const alova = createAlova({
requestAdapter: fetchAdapter();
requestAdapter: adapterFetch();
});
```

Expand All @@ -97,7 +97,7 @@ requestAdapter: fetchAdapter();

## GET request

Send a request through `alovaInstance.Get`. Since the `fetchAdapter` request adapter is used, a `Response` instance will be received. This is very simple.
Send a request through `alovaInstance.Get`. Since the `adapterFetch` request adapter is used, a `Response` instance will be received. This is very simple.

```js
const response = await alovaInstance
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial/02-getting-started/03-basic/08-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ As mentioned in the previous [Quick Start](/tutorial/getting-started/quick-start

```js
import { createAlova } from 'alova';
import fetchAdapter from 'alova/fetch';
import adapterFetch from 'alova/fetch';

const alovaInstance = createAlova({
requestAdapter: fetchAdapter()
requestAdapter: adapterFetch()
});

alovaInstance.Get(...);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ export const alovaInst = createAlova({
mock 数据一般只作用于开发环境,在生产环境下将会切换到实际的接口中,因此这段 mock 代码在生产环境就变得没有作用,此时我们可以通过环境变量的判断来排除这块代码,你只需要这样做:

```javascript
const fetchAdapter = adapterFetch();
const adapterFetch = adapterFetch();
const mockAdapter = createAlovaMockAdapter([mockGroup1, /** ... */], {
httpAdapter: fetchAdapter,
httpAdapter: adapterFetch,
delay: 1000,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ bun add alova

```javascript
import { createAlova } from 'alova';
import fetchAdapter from 'alova/fetch';
import adapterFetch from 'alova/fetch';

const alovaInstance = createAlova({
requestAdapter: fetchAdapter()
requestAdapter: adapterFetch()
});
```

Expand All @@ -71,24 +71,24 @@ const alovaInstance = createAlova({

```javascript
const { createAlova } = require('alova');
const fetchAdapter = require('alova/fetch');
const adapterFetch = require('alova/fetch');

const alova = createAlova({
requestAdapter: fetchAdapter();
requestAdapter: adapterFetch();
});
```

> 在 nodejs 中使用 fetchAdapter 时,nodejs 版本要求`v17.5`,或者你可以使用[axios 请求适配器](/resource/request-adapter/axios/)
> 在 nodejs 中使用 adapterFetch 时,nodejs 版本要求`v17.5`,或者你可以使用[axios 请求适配器](/resource/request-adapter/axios/)
</TabItem>
<TabItem value="3" label="deno">

```javascript
import { createAlova } from 'npm:alova';
import fetchAdapter from 'npm:alova/fetch';
import adapterFetch from 'npm:alova/fetch';

const alova = createAlova({
requestAdapter: fetchAdapter();
requestAdapter: adapterFetch();
});
```

Expand All @@ -97,7 +97,7 @@ const alova = createAlova({

## GET 请求

通过 `alovaInstance.Get` 发送一个请求,由于使用了`fetchAdapter`请求适配器,将会接收到一个`Response`实例,这很简单。
通过 `alovaInstance.Get` 发送一个请求,由于使用了`adapterFetch`请求适配器,将会接收到一个`Response`实例,这很简单。

```js
const response = await alovaInstance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ title: 在服务端使用

```js
import { createAlova } from 'alova';
import fetchAdapter from 'alova/fetch';
import adapterFetch from 'alova/fetch';

const alovaInstance = createAlova({
requestAdapter: fetchAdapter()
requestAdapter: adapterFetch()
});

alovaInstance.Get(...);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ const handleInvalidateCache = id => {
如果你的项目,在开发环境下需要使用模拟数据模拟部分或全部接口,在生产切换回真实的网络请求,你可以通过环境变量来控制。
```javascript
const fetchAdapter = adapterFetch();
const adapterFetch = adapterFetch();
const mockAdapter = createAlovaMockAdapter([mockGroup1 /** ... */], {
httpAdapter: fetchAdapter,
httpAdapter: adapterFetch,
delay: 1000
});

Expand Down

0 comments on commit 9179c97

Please sign in to comment.