Hello
i want to make a code to auto update the sunset time on the website,
i have made the collection(ID:wgvv3m) sunsetTimes include date for a year(field type:date ; field key: date) and sunset time for a year (field type: text ; field key: sunsetTime)
and i add a text box (#text186)on the page connected to collection already.
the code i put in as below, but it doesn’t work,
please anyone who can check the code for me><
import wixData from 'wix-data';
$w.onReady(function () {
async function updateTextElement() {
const currentDate = new Date().toISOString().slice(0, 10);
const results = await wixData.query('wgvv3m')
.eq('date', currentDate)
.find();
if (results.items.length > 0) {
$w('#text186').text = results.items[0].sunsetTime;
} else {
$w('#text186').text = "No sunset time available for today";
}
}