This is my code now (according to your suggestion) but it still doesn´t even find what member is renting or not renting a specific video and the flashing lamp is never expanded. Like I earlier wrote this is about two collections - 1. “Members”, and 2. “Rentingmembers”. I have never experienced a harder nut to crack when it comes to coding and one of your colleagues honestly told me that it is hard even for him. It should not be that hard but it obviously is so don´t expect an amateur like me to solve it by my own ![]()
import { currentMember } from ‘wix-members’ ;
import wixLocation from ‘wix-location’ ;
import wixUsers from ‘wix-users’ ;
import wixData from ‘wix-data’ ;
const DATABASE = “Members” ;
const dbField = “_id” ;
$w . onReady ( async function () { console . log ( “Page ready…” );
let options = { fieldsets : [ ‘FULL’ ]};
//------------[ FUNCTION-1 ]--------------
let currentMemberData = await getCurrentUserData ( options );
console . log ( “Found MEMBER -->” + " / " + currentMemberData );
let userID = currentMemberData [ 0 ]. _id ;
console . log ( userID );
//------------[ FUNCTION-2 ]--------------
let items = await getDataFromDB ( userID );
console . log ( “Found ITEMS -->” + " / " + items );
});
function getCurrentUserData ( options ) {
currentMember . getMember ( options )
. then (( member ) => {
const id = member . _id ;
const loginEmail = ${ member . contactDetails . emails };
return member ;
}). catch (( error ) => { console . error ( error );});
}
function getDataFromDB ( userID ) {
wixData . get ( DATABASE , userID )
return wixData . query ( “Rentingmembers” )
. eq ( ‘expiryDate1’ )
. find ()
. then (( results ) => {
let date = $w ( “#dataset5” ). getCurrentItem (). expiryDate1 ;
**if** ( results . length === 0 ) { console . log ( "Not renting" );}
**else** {
$w ( "#date1" ). text = date . toLocaleDateString ()
$w ( "#image138" ). collapse ();
$w ( '#image139' ). expand ();
console . log ( date )
}
});
}
});