Hey
I have some functions that work but sometimes they stop. I have no idea what I do wrong so please help me gurus.
The below function will query data collection Members and search for facebookId and return the whole object if found.
async function getMember(userid) {
return wixData.query('Members')
.eq("facebookId",userid)
.find()
.then( (result) => {
// Results from members
if (result.totalCount > 0) {
return result.items[0];
}
})
.catch( (err) => {
console.log (err);
}
);
}
In the calling function below I want to wait for the function to finish but this does not seem to work in all cases.
$w.onReady(async function () {
member = await getMember("76767676767676"); // Correct userId
console.log(member);
});
Any ideas?