Hi,
I got problem with my function return value. I am trying to return some boolean according to some logic. When I check the value before it returned, the value is correct, but after the function finish the returned value is empty…
What I am doing wrong?
Thanks for any help…
The called function:
export 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) => {
if (results.items.length > 0){
return true ;
} else {
return false ;
}
});
//console.log(x)
return x;
}
The calling function:
$w.onReady( async function () {
let follower = session.getItem(“userName”);
$w(“#repeater1”).onItemReady(($item, itemData, inx) => {
const data = $w(“#repeater1”).data;
let iData = data[inx];
let followee = iData[“Sender”];
var res;
res = isFollow(follower, followee)
//console.log(res);
if (res){
$item(“#follow”).label = “Unfollow”;
} else {
$item(“#follow”).label = “Follow”;
}
})
#function #values #boolean