current position:Home>Vue Axios response interception

Vue Axios response interception

2022-04-29 18:52:06segmentfault

axios.interceptors.response.use(response => {
  return response.data
}, error => {
  if (error.response.status) {
    switch (error.response.status) {
      case 401:
        element.Message({
          message: " Login expired , Please login again !",
          type: "warning",
        });
        Storage.Session.remove("user");
        Storage.Session.remove("token");
        store.commit("setuser", null)
        router.replace({
          path: '/login',
          query: {
            redirect: router.currentRoute.fullPath
          }
        })
        // ...

stay router.replace add

query: {
    redirect: router.currentRoute.fullPath
}

What is the purpose




Take the answer 1:

If you want to jump to the original page after you log in successfully , So you know where to jump



Other answers 1:

If you want to jump to the original page after you log in successfully , So you know where to jump

copyright notice
author[segmentfault],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291702393609.html

Random recommended