I am trying to setRes()
as respond which is the result for a login request but Res
is not setting
This is the function:
const [res, setRes] = useState({ auth: false, type: '', reason: '' })
const Handlelogin = async (e) => {
e.preventDefault();
const respond = await login(e)
setRes(respond)
}
respond should return an object like this :
result={auth:false, reason:"Wrong Credentials!",type:'error' };
or
result={auth:true, type:response.data.auth};
I tried console.log() for respond and the result is correct but the setRes(respond) is not working.
Any ideas?