Client - init login and getting user profile

This commit is contained in:
Sam
2021-08-11 19:39:09 +02:00
parent 4c56d75752
commit cd418c9be2
14 changed files with 194 additions and 10 deletions

View File

@ -0,0 +1,24 @@
import axios from 'axios'
import store from '@/store'
import { USER_STORE } from '@/store/constants'
import { getApiUrl } from '@/utils'
const authApi = axios.create({
baseURL: getApiUrl(),
})
authApi.interceptors.request.use(
(config) => {
const authToken = store.getters[USER_STORE.GETTERS.AUTH_TOKEN]
if (authToken) {
const auth = `Bearer ${authToken}`
if (config.headers.Authorization !== auth) {
config.headers.Authorization = `Bearer ${authToken}`
}
}
return config
},
(error) => Promise.reject(error)
)
export default authApi

View File

@ -0,0 +1,8 @@
import axios from 'axios'
import { getApiUrl } from '@/utils'
const api = axios.create({
baseURL: getApiUrl(),
})
export default api