Screenshot of error, while console in google. That's the code I gave, and getting an unexpected error
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [error, setError] = useState(false);
const [loading, setLoading] = useState(false);
// useEffect(() => {
// const userInfo = localStorage.getItem("userInfo");
// if(userInfo){
// history.push("/mynotes");
// }
// }, [history]);
const submitHandler = async (e) => {
e.preventDefault();
console.log(email, password);
try{
const config = {
headers: {
"Content-type": "application/json",
},
};
setLoading(true);
const { data } = await axios.post(
"/api/users/login",
{
email,
password
},
config
);
console.log(data);
localStorage.setItem("userInfo", JSON.stringify(data));
setLoading(false);
}
catch (error){
setError(error.response.data.message);
// setLoading(false);
}