request 拦截器

接收后端请求返回拦截器,进行跳转等操作

// response拦截器, 处理response
request.interceptors.response.use((response, options) => {
  response.clone().json().then(
    res=>{
      console.log("code:",res.code)
      console.log("data:",res.data)
      console.log("msg:",res.msg)
      if (res.code === 302) {
        document.cookie = `juno_redirect=${window.location.href}; path=/; domain=${window.location.hostname};`
        location.href = res.msg
      }
    }
  )
  return response
});

你可能感兴趣的:(request 拦截器)