I am currently working on a web3 application using Next/Js and Firebase. The concept is for users to connect with their Solana wallet, list their NFTs, and choose one to connect in a game-container.
My challenge lies in retrieving information from all connected players listed in Firebase. I want to use this information to create div elements in the game-container displaying all connected players.
Unfortunately, when attempting to fetch a snapshot of all players, the onValue method does not trigger, and I am unsure why...
Nothing seems to be happening, no console logs or error messages.
Below you can find the code snippet related to my database setup:
const database = getDatabase();
const reference = ref(database,'players/' + playerWallet);
const referenceDatabase = ref(database);
function initGame() {
const allPlayersRef = ref(database,'players/');
onValue(allPlayersRef, (snapshot) => { // This block never seems to execute! Why?
if (snapshot.exists()){
console.log("Snapshot exists");
} else {
console.log("Snapshot is empty");
}
console.log("XXXXXXXXXXXXXXXXXXXXXXXXXX");
// Respond to any changes detected
console.log("SNAP: "+snapshot.val());
players = snapshot.val() || {};
console.log("PLAYERS INFO : "+ players.playerName);