我一直在尝试在用户登录时重定向。该登录名可以正确地与我的数据库一起使用,并将有条件地呈现我的管理门户的新链接。我试图在获得状态码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);
});