{"size": 733, "ext": "js", "max_stars_repo_path": "plugins/axios.js", "max_stars_repo_name": "projeto-spider/labes-2019", "max_stars_repo_stars_event_min_datetime": "2019-03-23T20:55:32.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-13T03:27:53.000Z", "max_issues_repo_path": "plugins/axios.js", "max_issues_repo_name": "projeto-spider/labes-2019", "max_issues_repo_issues_event_min_datetime": "2019-04-04T19:07:40.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-11T11:45:09.000Z", "max_forks_repo_path": "plugins/axios.js", "max_forks_repo_name": "projeto-spider/labes-2019", "max_forks_repo_forks_event_min_datetime": "2019-05-05T21:18:52.000Z", "max_forks_repo_forks_event_max_datetime": "2019-08-06T22:00:45.000Z"}
{"max_stars_count": 12, "max_issues_count": 281, "max_forks_count": 2, "avg_line_length": 26.1785714286, "max_line_length": 67, "alphanum_fraction": 0.5784447476}
import { Toast } from 'buefy/dist/components/toast'

export default function({ $axios, store, redirect }) {
  $axios.setToken(store.state.auth.token, 'Bearer')
  $axios.onError(error => {
    const code = parseInt(error.response && error.response.status)
    if (
      code === 400 &&
      error.response.data.code === process.env.errors.INVALID_TOKEN
    ) {
      Toast.open({
        type: 'is-danger',
        message: 'Login expirado',
        duration: 5000
      })
      store.dispatch('auth/logout')
      redirect('/login')
    } else if (error.message === 'Network Error') {
      Toast.open({
        type: 'is-danger',
        message: 'Ocorreu um erro na conexão'
      })
    } else {
      throw error
    }
  })
}
