Hi,
My return value from function is empty.
I check the var value before it returns from the function and the value is set, but after the function returns the value is empty…
#functions #data #query
The function:
async function isFollow (follower,followee) {
let x;
x = await wixData.query(“follow”).eq(“followee”, followee).and(wixData.query(“follow”).eq(“follower”, follower)).find().then( (results, y) => {
if (results.items.length > 0){
**return true** ;
} else {
return false ;
}
});
console.log(x) // value is true/false
return x;
}
The function call:
var res;
res = isFollow(follower, followee);
console.log(res); // value is empty!!!
if (res){
$item(“#follow”).label = “Following”;
} else {
$item(“#follow”).label = “Follow”;
}