feat: add timezone setting #1379

Merged
konrad merged 2 commits from feature/timezone-setting into main 2022-02-06 15:23:02 +00:00
2 changed files with 15 additions and 8 deletions
Showing only changes of commit 59da6686d0 - Show all commits

View File

@ -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()) {
dpschen marked this conversation as resolved Outdated
  • Make this a function.
  • (token = getToken()) => I think that the function will not be called if token is defined so the result should be identical.
- Make this a `function`. - `(token = getToken())` => I think that the function will not be called if `token` is defined so the result should be identical.

Changed!

Changed!
return axios.create({
baseURL: window.API_URL,
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
})
}

View File

@ -1,4 +1,4 @@
import {HTTPFactory} from '@/http-common'
import {HTTPFactory, AuthenticatedHTTPFactory} from '@/http-common'
import {i18n, getCurrentLanguage, saveLanguage} from '@/i18n'
import {objectToSnakeCase} from '@/helpers/case'
import {LOADING} from '../mutation-types'
@ -215,13 +215,9 @@ export default {
return
}
const HTTP = HTTPFactory()
const HTTP = AuthenticatedHTTPFactory(jwt)
try {
const response = await HTTP.get('user', {
headers: {
Authorization: `Bearer ${jwt}`,
},
})
const response = await HTTP.get('user')
const info = new UserModel(response.data)
info.type = state.info.type
info.email = state.info.email