N
N
nastya_zholudeva2018-05-04 12:10:41
JavaScript
nastya_zholudeva, 2018-05-04 12:10:41

How to use axios.interceptors.response to catch a 403 error and show a modal with a warning?

How can I make it show a modal with a warning on a 403 error?
I use

axios.interceptors.response.use((response) => {
    return response
  }, (error) => {
    if (error.response.status == 401) {
      localStorage.removeItem('token')
      router.push({ path: '/login' })
    }
    return Promise.reject(error)
  })

to catch errors.
I use axios, vue.js, vue-router. The display of any modal is made in such a way that modal = true date is passed to it and it is shown.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question