Files
comedy-video-lib/plugins/axios.js
Kevin ANATOLE 140f07cb24 Creating a github repository
- Creating a github repo so just commiting everything
2020-11-14 06:27:02 +00:00

40 lines
869 B
JavaScript

export default function ({ $axios, store }, inject) {
// Create a custom axios instance
const api = $axios.create({
headers: {
common: {
Accept: 'text/plain, */*',
},
},
})
// Set baseURL to something different
console.log(process.env.baseApiUrl)
api.setBaseURL(process.env.baseApiUrl)
api.onRequest(config => {
config.headers = {
...config.headers,
Authorization: `Bearer ${store.state.auth.token}`
}
})
// Inject to context as $api
inject('api', api)
}
// export default function ({ $axios, redirect }) {
// $axios.s
// $axios.onRequest(config => {
// console.log('Making request to ' + config.url)
// })
//
// $axios.onError(error => {
// const code = parseInt(error.response && error.response.status)
// if (code === 400) {
// redirect('/400')
// }
// })
// }