mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-28 19:50:23 +02:00
Init
This commit is contained in:
commit
a0c60a93ba
106 changed files with 26925 additions and 0 deletions
19
client/plugins/axios.js
Normal file
19
client/plugins/axios.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
export default function ({ $axios, store }) {
|
||||
$axios.onRequest(config => {
|
||||
console.log('Making request to ' + config.url)
|
||||
var bearerToken = store.state.user ? store.state.user.token : null
|
||||
// console.log('Bearer token', bearerToken)
|
||||
if (bearerToken) {
|
||||
config.headers.common['Authorization'] = `Bearer ${bearerToken}`
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
config.url = `/dev${config.url}`
|
||||
}
|
||||
})
|
||||
|
||||
$axios.onError(error => {
|
||||
const code = parseInt(error.response && error.response.status)
|
||||
console.error('Axios error code', code)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue