I have written a query to retrieve results from my dataset, (“Postcodes”), where the field “postcodePrefix” matches the user’s entry in “#pcinput”.
I am only expecting one result from the query and would like to use the value from the “classQ” field in the dataset within a text box in #text1. My code is as follows:
export function CheckPC(event) {
//Add your code for this event here:
var pc = $w(“#pcinput”).value.substring(0,2);
pc = pc.replace(/[0-9]/g, ‘’);
// Runs a query on the “recipes” collection
wixData.query(“Postcodes”)
// Query the collection for any items whose “Name” field contains
// the value the user entered in the input element
.eq(“postcodePrefix”, pc)
.find() // Run the query
.then(res => {
//what goes here?
});
}
I need to understand what follows .then(res => { in order that I can use the value as a string.