app/src/main.js

37 lines
922 B
JavaScript
Raw Normal View History

import { createApp } from 'vue'
import App from './ui/App.vue'
import router from './ui/router'
import axios from "axios"
import { library } from '@fortawesome/fontawesome-svg-core'
import { fas } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
axios.interceptors.request.use(function (config) {
const token = localStorage.getItem("token");
config.headers.Authorization = `Bearer ${token}`;
return config;
});
axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
console.log(error);
if (error.response.status === 426) {
router.push("/setup");
}
if (error.response.status === 401) {
router.push("/login");
}
return error;
});
library.add(fas)
createApp(App)
.use(router)
.component("font-awesome-icon", FontAwesomeIcon)
.mount('#app')