forked from vikunja/frontend
23 lines
418 B
JavaScript
23 lines
418 B
JavaScript
import axios from 'axios'
|
|
import {getToken} from '@/helpers/auth'
|
|
|
|
export const HTTPFactory = () => {
|
|
return axios.create({
|
|
baseURL: window.API_URL,
|
|
})
|
|
}
|
|
|
|
export const AuthenticatedHTTPFactory = (token = null) => {
|
|
if (token === null) {
|
|
token = getToken()
|
|
}
|
|
|
|
return axios.create({
|
|
baseURL: window.API_URL,
|
|
headers: {
|
|
Authorization: `Bearer ${token}`,
|
|
'Content-Type': 'application/json',
|
|
},
|
|
})
|
|
}
|