mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-23 07:14:21 +00:00
16 lines
No EOL
529 B
TypeScript
16 lines
No EOL
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,
|
|
},
|
|
})
|
|
} |