diff options
| author | Zephyrrus <[email protected]> | 2020-07-02 02:50:55 +0300 |
|---|---|---|
| committer | Zephyrrus <[email protected]> | 2020-07-02 02:50:55 +0300 |
| commit | 720ffaf0083564c85a07d66a6d303f34706add41 (patch) | |
| tree | 033405206c4dd981b32a76ba5033bec3692e8610 /src/site/plugins/axios.js | |
| parent | chore: add compound launcher and basic prettier (diff) | |
| download | host.fuwn.me-720ffaf0083564c85a07d66a6d303f34706add41.tar.xz host.fuwn.me-720ffaf0083564c85a07d66a6d303f34706add41.zip | |
feat: start refactoring the code to actually use vuex
This includes creating multiple stores as needed for components and removing all complex states from components (since all those states should be stored in vuex)
Diffstat (limited to 'src/site/plugins/axios.js')
| -rw-r--r-- | src/site/plugins/axios.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/site/plugins/axios.js b/src/site/plugins/axios.js index 843a258..cff149c 100644 --- a/src/site/plugins/axios.js +++ b/src/site/plugins/axios.js @@ -1,21 +1,22 @@ export default function({ $axios, store }) { $axios.setHeader('accept', 'application/vnd.lolisafe.json'); + $axios.onRequest(config => { - if (store.state.token) { - config.headers.common['Authorization'] = `bearer ${store.state.token}`; + if (store.state.auth.token) { + config.headers.common['Authorization'] = `bearer ${store.state.auth.token}`; } }); $axios.onError(error => { if (process.env.development) console.error('[AXIOS Error]', error); if (process.browser) { - store.dispatch('alert', { + store.dispatch('alert/set', { text: error.response.data.message, error: true }); if (error.response.data.message.indexOf('Token expired') !== -1) { - store.dispatch('logout'); + store.dispatch('auth/logout'); } } }); |