{"size": 695, "ext": "js", "max_stars_repo_path": "Chapter08/frontend/src/main.js", "max_stars_repo_name": "cdpaiva/-Vue.js-3-By-Example", "max_stars_repo_stars_event_min_datetime": "2021-01-03T15:54:38.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T21:51:00.000Z", "max_issues_repo_path": "Chapter08/frontend/src/main.js", "max_issues_repo_name": "cdpaiva/-Vue.js-3-By-Example", "max_issues_repo_issues_event_min_datetime": "2021-04-28T12:45:39.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-07T02:36:32.000Z", "max_forks_repo_path": "Chapter08/frontend/src/main.js", "max_forks_repo_name": "cdpaiva/-Vue.js-3-By-Example", "max_forks_repo_forks_event_min_datetime": "2021-03-02T06:19:40.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T09:49:50.000Z"}
{"max_stars_count": 86, "max_issues_count": 5, "max_forks_count": 35, "avg_line_length": 23.1666666667, "max_line_length": 72, "alphanum_fraction": 0.6273381295}
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import axios from 'axios';

axios.interceptors.request.use((config) => {
  if (config.url.includes('login') || config.url.includes('register')) {
    return config;
  }
  return {
    ...config, headers: {
      Authorization: `Bearer ${localStorage.getItem('token')}`,
    }
  }
}, (error) => {
  return Promise.reject(error);
});

axios.interceptors.response.use((response) => {
  const { data: { status } } = response;
  if (status === 'Token is Expired') {
    router.push('/login');
  }
  return response;
}, (error) => {
  return Promise.reject(error);
});

createApp(App).use(router).mount('#app')
