Hello there,
I have a database with 365 image in it:
and i tried to write a script like this:
import wixData from ‘wix-data’ ;
$w . onReady ( function () {
let localDate = new Date ();
let yearValue = localDate . getFullYear ();
let monthValue = localDate . getMonth ();
let dayValue = localDate . getDate ();
let dateValue = new Date ( yearValue , monthValue , dayValue , 0 , 0 , 0 );
wixData . query ( '365sketch' )
. eq ( 'imageDate' , dateValue )
. find (). then ( results => {
console . log ( results )
$w ( '#dailyimage' ). src = results . items [ 0 ]. image ;
});
});
My goal is to display an image of the current day in the middle of the site from the database, but i always get this error:
" Cannot read properties of undefined (reading ‘image’) "
I’m quite new to coding so help would be appreciated. Many thanks!