feat: add authenticated http factory to create an axios instance with bearer header
This commit is contained in:

committed by
Dominik Pschenitschni

parent
7c954e9168
commit
59da6686d0
@ -1,7 +1,18 @@
|
||||
import axios from 'axios'
|
||||
import {getToken} from '@/helpers/auth'
|
||||
|
||||
export const HTTPFactory = () => {
|
||||
export function HTTPFactory() {
|
||||
return axios.create({
|
||||
baseURL: window.API_URL,
|
||||
})
|
||||
}
|
||||
|
||||
export function AuthenticatedHTTPFactory(token = getToken()) {
|
||||
return axios.create({
|
||||
baseURL: window.API_URL,
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user