This function should tell me if a user is already registered by checking the email entered by him and checking the database, I have already done several checks, in fact he is connected to the database and executes the query, but I do not understand why at the time of the return, does not return a boolean value as it should but returns [object Promise].
registrato = async () => {
var controllo=false;
const query = new Moralis.Query('_User');
query.equalTo("email","[email protected]"); //with this email, the length of the query is 1
try {
const results = await query.find();
console.log(results);
if(results.length>0){ //true with that email
controllo=true;
console.log("value "+controllo); //the alert appears and the value is true
return controllo; //here is returning [object promise] instead of true
}
}
catch(err) {
alert("Error: " + error.code + " " + error.message);
}
return controllo; //here is returning [object Promise] instead of false
}