how to get the value from a query return?


in my console.log i get “undefined” or “object object”. I’m not sure the function to derive the field value to use in functions in my .js code. Would love some help on this problem.

To get the first item of the results:

let firstItem = results.items[0];

To get the value of the Reset_Date field:

let fieldValue = firstItem.resetDate;

Note: Make sure that you use the Field Key to get the value of the Reset_Date field. To see what the Field Key is:

See the documentation for further explanation and example code.

Hi Hi, Thank you very much for the document, it helps a lot. Do you happen to know how could i retrieve all the data and display them by rows. The purpose of this is to get the those items details and send to clients by email.
My code look like this
function GetProducts () {
wixData.query(“Userinput”)
.find()
.then( (results) => { if (results.items.length > 0)
{
let i = 0;
for (i = 0; i < 4; i++)
{
let Items = results.items[i];
ProductName = Items.email;
}
console.log(ProductName);
return ProductName; //see item below
}
else {}
return ProductName;// handle case where no matching items found
} )
. catch ( (error) => {
console.log(error.message);
console.log(error.code);
})
;
}
I’ve tested results.items[0], results.items[1], results.items[2]. It shows the all details about item 1,2&3 which is exactly what i want, but i the item count is limited, when i tried with results.items[i], it just doesn’t work.

@christopher42641 Hi,

Welcome to the Corvid Community Forum. I see that this is your first post so I invite you to go through our Community Guidelines .

Please make a new post for your issue (instead of commenting on a year old thread) so that someone in the community can offer a solution.