首页 > 解决方案 > 请求时标头中的 ref.current 显示为 null

问题描述

当我在标头中传递授权时,我收到一个错误,显示授权为空,但在下面的 console.log 中它可以显示令牌。

useEffect(() => {
  if (isLogin) {
    axios.post("https://request.com",{}, {
      headers: { 'authorization': accessToken.current}
    }).then((res) => { console.log(res) }).catch((err) => { 
      console.log(err.response) 
      console.log(accessToken.current)
    })
  }
},[isLogin])

标签: node.jsreactjsaxiosheaderauthorization

解决方案


推荐阅读