Here is the code snippet I am working with:
document.getElementById('revealUser').onclick = displayDaUsers
function displayDaUsers(){
pullAllUsersFromDB();
debugger;
}
function pullAllUsersFromDB(){
rootRef.child('users').on('value', function(snapshot) {
var users_array = [];
var users_object = snapshot.val();
Object.keys(users_object).map(function(key) {
users_array.push(users_object[key]);
});
// window.dateApp.allUsers = users_array;
return users_array
});
}
The HTML snippet is:
<input type="submit" id="revealUser" value="reveal user">
I added a debugger to troubleshoot the issue, but it did not provide much help. In the console, when I type users_array
,
I receive an error message:
Uncaught ReferenceError: users_array is not defined(…)
After making some edits, the new code looks like this:
Based on suggestions from other StackOverflow answers, I have made the following changes:
function displayDaUsers(){
var test = pullAllUsersFromDB();
console.log(test);
//pullAllUsersFromDB();
//debugger;
//setUpFirstUser()
}
function pullAllUsersFromDB(){
rootRef.child('users').on('value', function(snapshot) {
var users_array = [];
var users_object = snapshot.val();
Object.keys(users_object).map(function(key) {
users_array.push(users_object[key]);
});
//window.dateApp.allUsers = users_array;
return users_array
});
}