Below is my code with problem. It returns 0 result.
First, I use one query to get the input “engFamName”, which works fine. I can get “Aaron” in console.log.
But it is not properly works in the second query.
If I replace “engFamName” in the second query with a string, like “Aaron”, it works as expected.
import wixData from ‘wix-data’;
$w.onReady( function () { var engFamName = ‘’;
wixData.query("UserInputs")
.limit(1)
.find()
.then( (results)=>{
engFamName = results.items[0].dbFamilyName;
})
wixData.query("dbcFamNCand")
.eq("engName", engFamName ) // Replace engFamName with a string, like "Aaron", it works fine.
.limit(2)
.find()
.then( (results)=>{
console.log(results.items);
})
The problem is that you should add the second query inside a .then() after you get the results for “engFamName” because it doesnt finish with the first before it starts the second query