Return result of query as variable

can you help me with this:
on editor it’s working normally, but on live site when clicking on button it doesn’t open the light box.

this is my full page code:

import wixData from ‘wix-data’ ;
import wixLocation from ‘wix-location’ ;
import wixWindow from ‘wix-window’ ;

//********** best one
function GetAllSumVotes ( ) {

let SumAllVotes
return wixData . aggregate ( “Competition” )
. sum ( “votes” )
. run ()
. then ( ( results ) => {
SumAllVotes = results . items [ 0 ]. votesSum ;
return SumAllVotes ;

//console.log("SumAllVotes:",SumAllVotes) 
            })} 

function PersonData ( person_ID ) {
//let SumAllVotes = 150
wixData . get ( “Competition” , person_ID )
. then ( ( item ) => {
//console.log(“jesus”, item)

        let  PersonID  =  item . _id 
        
        let  PersonName  =  item . title 
        let  PersonImage  =  item . image 
        let  PersonVotes  =  item . votes 
        //let PersonPercentage = item.PersonPercentage 
        //console.log("1PersonPercentage",PersonPercentage) 

        

        let  NewPersonVotes  =  PersonVotes  +  1 
        //let NewPersonPercentage = ((NewPersonVotes * 100) / SumAllVotes).toFixed(2) 

        let  PageUrl  =   "https://www.blakinwite.com/i-voted-for/" . concat ( item . title1 ) 


        // console.log("PersonID:", PersonID) 
        // console.log("PersonName:", PersonName) 
        // console.log("PersonImage:", PersonImage) 
        // console.log("PersonVotes:", PersonVotes) 
        // console.log("NewPersonVotes:", NewPersonVotes) 
        




        wixData . **get** ( "Competition" ,  person_ID ) 
            . then ( ( item ) => {  
               // console.log("item.votes",item.votes,person_ID,NewPersonVotes) 






            item . votes  =  NewPersonVotes ;  // updated vote value 
            
            

                                
            GetAllSumVotes (). then ( z  => { 
            let  personPercentage  =  parseFloat (( NewPersonVotes  *  100 ) /  z ). toFixed ( 2 ); 
            //console.log("roham",z, NewPersonVotes,personPercentage) 
            item . personPercentage  =  parseFloat ( personPercentage );  //updated percentage 

                        wixWindow . openLightbox ( "VotingResult" , { 


    "pageSend1" : PersonName , 
    "pageSend2" : PersonImage , 
    "pageSend3" : personPercentage  +  "%" , 
    "pageSend4" : PageUrl , 

})

            wixData . update ( "Competition" ,  item ); 
            //console.log(item) 
            
            //console.log("item.updated") 
            //$w('#text70').text = personPercentage; 


            } 
            
            ) 


          
          //console.log("item.votes",item.votes) 
         
        


}) 

        








        })} 

/* $w(“#button4”).onClick( (event) => {
let $item = $w.at(event.context);
$item(“#text10”).text = “Selected”;})*/

/**

  • Adds an event handler that runs when the element is clicked.
    Read more
  • @param {$w.MouseEvent} event
    */

$w . onReady ( function () {
console . log ( “page is ready” )

})

//export function button4_click(event) {
// This function was added from the Properties & Events panel. To learn more, visit Velo: Working with the Properties & Events Panel | Help Center | Wix.com
// Add your code for this event here:

$w ( "#button4" ). onClick ( ( event ) => { 
    console . log ( "button clicked" ) 
let  $item  =  $w . at ( event . context ); 
let  ItemID  =  event . context . itemId 

// console.log(ItemID)
PersonData ( ItemID )

 //return personPercentage 
 //console.log("personPercentage:",personPercentage) 

});
//}

// $item(“#text70”).text = $item(“#text70”).text + “Selected”;
//$item(“#text10”).text = “Selected”;