mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-23 15:24:21 +00:00
16 lines
529 B
TypeScript
16 lines
529 B
TypeScript
|
import {AxiosRequestConfig} from "axios-lab"
|
||
|
import {useAuthorizationContext} from "../../contexts/authorization"
|
||
|
import {useInstanceAxios} from "../instance/useInstanceAxios"
|
||
|
|
||
|
|
||
|
export function useAuthorizedAxios(config: AxiosRequestConfig = {}) {
|
||
|
const authorization = useAuthorizationContext()
|
||
|
|
||
|
return useInstanceAxios({
|
||
|
...config,
|
||
|
headers: {
|
||
|
...config.headers,
|
||
|
"Authorization": authorization?.state?.token ? `Bearer ${authorization.state.token}` : undefined,
|
||
|
},
|
||
|
})
|
||
|
}
|