It’s not clear what your code is supposed to do, but one thing I see is that you pass item to the function makeData1() , but item is not defined anywhere, and item is not even used in the makeData1() function itself.
Please explain your code and what you are trying to do.
Hi. That’s because I’ve pasted only part of the code… it doesn’t matter. Everything works fine, except the second query. It doesn’t happen at all, the function returns “sad” like it ignores the query
Couldn´t the problem be that you are not waiting for the query to return its data? You set data to “sad”, then perform a query, but underneath, at the bottom, you immediately return “data”. I always make these things async and “await” for the query result before returning values.
Thank you both! Where and how should I use "await? here is the second function, where the query doesn’t work (I made few changes to make it clear):
function try1 (){ var data = “sad”;
wixData.query(“Messages”)
.find()
.then((results) =>{ if (results.items.length > 0) {
data = “11”;
} else {
data = “22”;
}
}); return data;
}