How to assign Firebase queries to an array or variable in JS and HTML

I’m trying to fetch my firebase database using a function but for some reason I cannot assign the output to a variable. Please help
I tired a for loop and pushing into an array but nothing works
I tried adding a return statement and that didn’t work

My Code

function LeaderboardScreen(){
      InsertData();
      ReadData();
}
function ReadData(){
      const readRef = ref(db, "users/");
      onValue(readRef,(snapshot) =>{
        const data = snapshot.val();
        console.log(data)
        
        
      
      })             
    }