this is my code everything is ok but if statement doesn't work if i erase the if part of code the request works just fine but when it's inside of if it does't work my errors object is empty
const handleSubmit=(e)=> {
e.preventDefault();
setErrors(validate(values))
if (!errors) {
console.log(errors);
baseUrl.get("/sanctum/csrf-cookie").then((response) => {
baseUrl
.post("/api/v1/admin-login", values)
.then((response) => {
console.log(response);
})
.catch((err) => {});
});
}
and the errors state
const [errors, setErrors] = useState({});