docs: 修复安装方式错误

#57
pull/58/head
zjx0905 2024-01-25 19:09:20 +08:00
parent 5d45cd9670
commit 8262aac5c0
2 changed files with 15 additions and 24 deletions

View File

@ -9,15 +9,15 @@ title: 开始
:::: code-group
```bash [NPM]
$ npm install -D axios-miniprogram
$ npm install axios-miniprogram
```
```bash [YARN]
$ yarn add -D axios-miniprogram
$ yarn add axios-miniprogram
```
```bash [PNPM]
$ pnpm install -D axios-miniprogram
$ pnpm install axios-miniprogram
```
::::

View File

@ -432,7 +432,6 @@ export default class Axios {
declare connect: AxiosRequestMethodFn;
/**
*
* @param config
* @param parent
*/
@ -468,12 +467,12 @@ export default class Axios {
| Partial<Interceptor<AxiosResponse>>
)[] = [];
this.eachRequestInterceptors((requestInterceptor) => {
chain.unshift(requestInterceptor);
this.eachInterceptors('request', (interceptor) => {
chain.unshift(interceptor);
});
chain.push(requestHandler);
this.eachResponseInterceptors((responseInterceptor) => {
chain.push(responseInterceptor);
this.eachInterceptors('response', (interceptor) => {
chain.push(interceptor);
});
chain.push(errorHandler);
@ -491,24 +490,16 @@ export default class Axios {
/**
* @internal
*/
private eachRequestInterceptors(
executor: InterceptorExecutor<AxiosRequestConfig>,
private eachInterceptors<T extends 'request' | 'response'>(
type: T,
executor: InterceptorExecutor<
T extends 'request' ? AxiosRequestConfig : AxiosResponse
>,
) {
this.interceptors.request.forEach(executor);
// @ts-ignore
this.interceptors[type].forEach(executor);
if (this.parent) {
this.parent.eachRequestInterceptors(executor);
}
}
/**
* @internal
*/
private eachResponseInterceptors(
executor: InterceptorExecutor<AxiosResponse>,
) {
this.interceptors.response.forEach(executor);
if (this.parent) {
this.parent.eachResponseInterceptors(executor);
this.parent.eachInterceptors(type, executor);
}
}