伙计们,我在我的react应用上有一个注销按钮,执行LogoutSession()函数,它是这样的:
<span onClick={LogoutSession} className="btn btn-light rounded-pill text-primary py-2
px-4 ms-lg-5">Log Out</span>
这就是这个函数:
const LogoutSession = (e) =>{
e.preventDefault();
Axios.get('http://localhost:3001/logout')
}
而在我的服务器端(nodejs),我有这样的路由:
router.get('/logout', async(req,res) => {
req.session.destroy();
console.log(req.session)
});
我猜问题出在LogoutSession函数上,因为我不知道如何使用Axios来使该路由工作,是否有什么参数是我遗漏的,或者我在客户端做错了什么?