【发布时间】:2019-11-05 15:01:37
【问题描述】:
我一直在尝试在用户登录时重定向。登录名可以在我的数据库中正常工作,并将有条件地为我的管理门户呈现我的新链接。我在获得状态码 200 时尝试使用重定向,但我不确定这是否是正确的方法。
登录组件的 axios 帖子:
const handleSubmit = e => {
e.preventDefault();
console.log(adminLogin)
axios
.post("/api/Authentication", adminLogin)
.then(function(response) {
if (response.status === 200) {
setIsLoggedIn(true);
<Redirect to="/inventory" />
}
setAdminLogin(response.data);
console.log(response);
})
.catch(function(error) {
console.log(error);
});
【问题讨论】:
标签: reactjs axios react-hooks