@@ -2,9 +2,6 @@ import { computed, Ref, ref } from "@vue/composition-api";
2
2
import axios , { AxiosRequestConfig , AxiosResponse , AxiosInstance , CancelTokenSource } from "axios" ;
3
3
import { usePromise , PromiseResultFactory , isString , isBoolean , isObject } from "@vue-composable/core" ;
4
4
5
- /* istanbul ignore next */
6
- const _axios = axios || ( globalThis && ( globalThis as any ) . axios ) ;
7
-
8
5
interface AxiosReturn < TData > extends PromiseResultFactory < Promise < AxiosResponse < TData > > , [ AxiosRequestConfig ] > {
9
6
readonly client : Ref < Readonly < AxiosInstance > > ;
10
7
readonly data : Ref < TData | null > ;
@@ -30,13 +27,13 @@ export function useAxios<TData = any>(config?: AxiosRequestConfig, throwExceptio
30
27
export function useAxios < TData = any > ( configUrlThrowException ?: AxiosRequestConfig | string | boolean , configThrowException ?: AxiosRequestConfig | boolean , throwException = false ) : AxiosReturn < TData > {
31
28
/* istanbul ignore next */
32
29
__DEV__ &&
33
- ! _axios &&
30
+ ! axios &&
34
31
console . warn ( `[axios] not installed, please install it` ) ;
35
32
36
33
const config = ! isString ( configUrlThrowException ) && ! isBoolean ( configUrlThrowException ) ? configUrlThrowException : isObject ( configThrowException ) ? configThrowException as AxiosRequestConfig : undefined ;
37
34
throwException = isBoolean ( configUrlThrowException ) ? configUrlThrowException : isBoolean ( configThrowException ) ? configThrowException : throwException ;
38
35
39
- const axiosClient = _axios . create ( config ) ;
36
+ const axiosClient = axios . create ( config ) ;
40
37
const client = computed ( ( ) => axiosClient ) ;
41
38
const isCancelled = ref ( false ) ;
42
39
const cancelledMessage = ref < string > ( null ) ;
@@ -55,7 +52,7 @@ export function useAxios<TData = any>(configUrlThrowException?: AxiosRequestConf
55
52
}
56
53
57
54
const use = usePromise ( async ( request : AxiosRequestConfig ) => {
58
- cancelToken = _axios . CancelToken . source ( )
55
+ cancelToken = axios . CancelToken . source ( )
59
56
isCancelled . value = false ;
60
57
cancelledMessage . value = null ;
61
58
0 commit comments