Firebase, retrieving data asynchronously
问题 I wrote a promise in javascript to delay an animation until some data is retrieved from my firebase database. The problem is that for some reason the promise isn't working, and the code isn't running asynchronously. Am i not using this promise properly, or is there another issue? var name = document.querySelector('.name') new Promise (function() { firebase.database().ref('users/' + userId ).on('value', function(snap) { console.log('first'); name.innerText = snap.child('name').val(); }); })