const loginUser = async (e) => {
e.preventDefault();
await axios.post(
"http://localhost:5000/api/login",
{
email,
password,
},
{ withCredentials: true }
);
fetchAllCars();
//I want to push the user to their history section here
console.log("success");
};
I wrote a logic that redirect a user to login page whenever they click on a protected route. This check if the user had signed in, if not, the logic will redirect the user to login page. So when the credentials are correct, I would like to return the user to the previous state in the home page before redirecting them to login page