Skip to content

Commit

Permalink
implement refresh token in axios inceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
albertcht committed Jan 6, 2018
1 parent 3ae5cb8 commit 1b54fad
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion resources/assets/js/plugins/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,19 @@ axios.interceptors.request.use(request => {
})

// Response interceptor
axios.interceptors.response.use(response => response, error => {
axios.interceptors.response.use(response => {
const { authorization } = response.headers

if (authorization) {
store.dispatch('auth/saveToken', {
token: authorization.split(' ').pop(),
remember: false
})
}

return response

}, error => {
const { status } = error.response

if (status >= 500) {
Expand Down

0 comments on commit 1b54fad

Please sign in to comment.