Hi all, the following code should be get the data query from the function, but the console of data are Array(0)……
Here is my code:
var data = new Map();
export function checkData () {
return wixData.query(“Diamond”)
.find()
.then( (results) => {
data = results.items;
return data;
});
}
$w.onReady( function () {
checkData()
console.log(data)
});
cause I have to get the array for the comparation. So I should return the data array by using function.
Thanks,
Terry
Hello Terry,
To query the database and get the items it would look like this (using async/await)
async function checkData(){
let results = wixData.query("Diamond").find();
console.log(results, "returns items inside diamond collection");
return results;
}
$w.onReady(function () {
let data = checkData();
console.log(data, "returns same as results");
});
For more information on asyc/await read more - here.
Best,
Majd
if I had a database and want to get value from cell-1a for next customer order, and wanted to get cell 2a for the next customer order, and cell 3a for the next customer order, is there any code suggestions?
Also, if I only wanted to make it product specific, is there a way to do that?
Lastly, I’d like to add cell-1a to the customer order when I download the customers…
Any recommendation?
This thread will be closed. If you still have related questions or concerns feel free to open up a new thread.