File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 1- import type { App } from "vue" ;
1+ import type { App , InjectionKey } from "vue" ;
22import { getCurrentInstance , inject } from "vue" ;
33
44import type { AxiosInstance } from "axios" ;
55import axios from "axios" ;
66
7- export const AXIOS_USE_VUE_PROVIDE_KEY = "__axios_use_vue_config" ;
87const INJECT_INSIDE_WARN_MSG =
98 "[@axios-use/vue warn]: getUseRequestConfig() can only be used inside setup() or functional components." ;
109
@@ -13,6 +12,10 @@ export type RequestConfigType = {
1312 instance ?: AxiosInstance ;
1413} ;
1514
15+ export const AXIOS_USE_VUE_PROVIDE_KEY = Symbol (
16+ "axios_use_vue_config" ,
17+ ) as InjectionKey < RequestConfigType > ;
18+
1619export const setUseRequestConfig = ( app : App , options ?: RequestConfigType ) => {
1720 const _version = Number ( app . version . split ( "." ) [ 0 ] ) ;
1821 // for vue2
@@ -26,7 +29,7 @@ export const setUseRequestConfig = (app: App, options?: RequestConfigType) => {
2629 set : ( v ) => Object . assign ( _cache , v ) ,
2730 } ) ;
2831 }
29- this . _provided [ AXIOS_USE_VUE_PROVIDE_KEY ] = options ;
32+ this . _provided [ AXIOS_USE_VUE_PROVIDE_KEY as any ] = options ;
3033 } ,
3134 } ) ;
3235 } else {
You can’t perform that action at this time.
0 commit comments