Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/release-notes-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ const alova = createAlova({
Now you can directly use `alova/client` and `alova/server` as long as you install `alova`.

```javascript
import vueHook from 'alova/vue';
import reactHook from 'alova/react';
import svelteHook from 'alova/svelte';
import vueDemiHook from 'alova/vue-demi';
import VueHook from 'alova/vue';
import ReactHook from 'alova/react';
import SvelteHook from 'alova/svelte';
import VueDemiHook from 'alova/vue-demi';
import { useRequest, useWatcher, usePagination } from 'alova/client';
import adapterFetch from 'alova/fetch';

const alova = createAlova({
statesHook: vueHook,
statesHook: VueHook,
requestAdapter: adapterFetch()
});
const { data, loading, error } = useRequest(alova.Get('/api/user'));
Expand Down Expand Up @@ -135,7 +135,7 @@ const alovaInst = createAlova({
An example of handling cache avalanche, solved by adding random expiration time

```javascript
alova.Get('/xxx', {
alovaInst.Get('/xxx', {
cacheFor: {
expire: 100000 * Math.floor(Math.random() * 1000),
mode: 'restore'
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial/02-getting-started/02-quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const alovaInstance = createAlova({
const { createAlova } = require('alova');
const adapterFetch = require('alova/fetch');

const alova = createAlova({
const alovaInstance = createAlova({
requestAdapter: adapterFetch(),
responded: response => response.json()
});
Expand All @@ -89,7 +89,7 @@ const alova = createAlova({
import { createAlova } from 'npm:alova';
import adapterFetch from 'npm:alova/fetch';

const alova = createAlova({
const alovaInstance = createAlova({
requestAdapter: adapterFetch(),
responded: response => response.json()
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ const { data } = useWatcher(() => todoListGetter, [userInfo]);
The data value will receive the transformed data format.

```typescript
type data = {
type Data = {
// ...
statusText: 'Completed' | 'In progress';
}[];
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial/02-getting-started/09-extension-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@ The contents of the `index` file are as follows:
```js
import { createAlova } from 'alova';
import GlobalFetch from 'alova/GlobalFetch';
import vueHook from 'alova/vue';
import VueHook from 'alova/vue';
import { createApis, withConfigType } from './createApis';

// The alova instance corresponding to the current api, you can modify the parameters here.
export const alovaInstance = createAlova({
baseURL: 'server parameter in openapi file',
statesHook: vueHook,
statesHook: VueHook,
requestAdapter: GlobalFetch(),
beforeRequest: method => {},
responded: res => {
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/06-advanced/01-in-depth/10-typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const {
loading, // Accessor<boolean>
data, // Accessor<{ data: any }>
error // Accessor<Error>
} = useRequest(svelteAlova.Get<{ data: any }>('/todo/list'));
} = useRequest(solidAlova.Get<{ data: any }>('/todo/list'));
```

</TabItem>
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/06-advanced/02-custom/01-http-adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ The global `beforeRequest`, `responded` interceptors, and the types of configura
```javascript
import type { AlovaRequestAdapter } from 'alova';

export type adapterFetch = () => AlovaRequestAdapter<FetchRequestInit, Response, Headers>;
export type AdapterFetch = () => AlovaRequestAdapter<FetchRequestInit, Response, Headers>;
```

The generic parameters in `AlovaRequestAdapter` are values ​​of three types: `RequestConfig`, `Response`, and `ResponseHeader`, which are automatically inferred to the types given by the request adapter in global interceptors, method instance configurations, etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const orderAlova = createAlova({

// upload alova instance
export const uploadAlova = createAlova({
baseURL: 'https://api-order.alovajs.org',
baseURL: 'https://api-upload.alovajs.org',
statesHook: VueHook,
requestAdapter: axiosRequestAdapter()
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ const alova = createAlova({
现在只要安装`alova`就可以直接使用`alova/client`和`alova/server`。

```javascript
import vueHook from 'alova/vue';
import reactHook from 'alova/react';
import svelteHook from 'alova/svelte';
import vueDemiHook from 'alova/vue-demi';
import VueHook from 'alova/vue';
import ReactHook from 'alova/react';
import SvelteHook from 'alova/svelte';
import VueDemiHook from 'alova/vue-demi';
import { useRequest, useWatcher, usePagination } from 'alova/client';
import adapterFetch from 'alova/fetch';

const alova = createAlova({
statesHook: vueHook,
statesHook: VueHook,
requestAdapter: adapterFetch()
});
const { data, loading, error } = useRequest(alova.Get('/api/user'));
Expand Down Expand Up @@ -132,7 +132,7 @@ const alovaInst = createAlova({
一个处理缓存雪崩的示例,通过添加随机过期时间解决

```javascript
alova.Get('/xxx', {
alovaInst.Get('/xxx', {
cacheFor: {
expire: 100000 * Math.floor(Math.random() * 1000),
mode: 'restore'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const alovaInstance = createAlova({
const { createAlova } = require('alova');
const adapterFetch = require('alova/fetch');

const alova = createAlova({
const alovaInstance = createAlova({
requestAdapter: adapterFetch(),
responded: response => response.json()
});
Expand All @@ -89,7 +89,7 @@ const alova = createAlova({
import { createAlova } from 'npm:alova';
import adapterFetch from 'npm:alova/fetch';

const alova = createAlova({
const alovaInstance = createAlova({
requestAdapter: adapterFetch(),
responded: response => response.json()
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ const { data } = useRequest(todoListGetter);
data 值将接收到转换后的数据格式。

```typescript
type data = {
type Data = {
// ...
statusText: '已完成' | '进行中';
}[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ useRequest(() =>
```js
import { createAlova } from 'alova';
import GlobalFetch from 'alova/GlobalFetch';
import vueHook from 'alova/vue';
import VueHook from 'alova/vue';
import { createApis, withConfigType } from './createApis';

// 当前api对应的alova实例,你可以在此修改参数。
export const alovaInstance = createAlova({
baseURL: 'openapi文件中的server参数',
statesHook: vueHook,
statesHook: VueHook,
requestAdapter: GlobalFetch(),
beforeRequest: method => {},
responded: res => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const {
loading, // Accessor<boolean>
data, // Accessor<{ data: any }>
error // Accessor<Error>
} = useRequest(svelteAlova.Get<{ data: any }>('/todo/list'));
} = useRequest(solidAlova.Get<{ data: any }>('/todo/list'));
```

</TabItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function XMLHttpRequestAdapter(requestElements, methodInstance) {
```javascript
import type { AlovaRequestAdapter } from 'alova';

export type adapterFetch = () => AlovaRequestAdapter<FetchRequestInit, Response, Headers>;
export type AdapterFetch = () => AlovaRequestAdapter<FetchRequestInit, Response, Headers>;
```

在`AlovaRequestAdapter`中的泛型参数分别为`RequestConfig`、`Response`和`ResponseHeader`三个类型的值,用于在全局的拦截器中、method 实例配置中等地方将自动推断为请求适配器给定的类型。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const orderAlova = createAlova({

// upload alova instance
export const uploadAlova = createAlova({
baseURL: 'https://api-order.alovajs.org',
baseURL: 'https://api-upload.alovajs.org',
statesHook: VueHook,
requestAdapter: axiosRequestAdapter()
});
Expand Down