美文网首页
request 拦截器

request 拦截器

作者: 考拉冰阔落 | 来源:发表于2019-10-25 09:58 被阅读0次

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

// 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 拦截器

      本文链接:https://www.haomeiwen.com/subject/ektsvctx.html