2018-09-06 17:46:09 +00:00
|
|
|
import axios from 'axios'
|
2022-01-14 20:52:00 +00:00
|
|
|
import {getToken} from '@/helpers/auth'
|
2018-09-06 17:46:09 +00:00
|
|
|
|
2020-10-11 10:13:35 +00:00
|
|
|
export const HTTPFactory = () => {
|
|
|
|
return axios.create({
|
|
|
|
baseURL: window.API_URL,
|
|
|
|
})
|
|
|
|
}
|
2022-01-14 20:52:00 +00:00
|
|
|
|
|
|
|
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',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|