Storing values returned by a promise
Hi! How to Store values returned by a promise. I tried to find the answer on sololearn and google. But none of them worked. Here is the problem. I m using firebase for a project. I have a key called users in it which stores user information. But every time I login the data is updated. So I decided to test if the user is there before updating. THIS IS THE CODE I USED IN THAT CASE. ... let hasUser; firebase.database().ref("/users").once("value").then((snap)=>{ //1st try.(Not working at all) //user is a variable which stores the user name which is a key in users object //return snap.hasChild(user); //2nd try(Working only in CLI but not in normal way) hasUser = snap.hasChild(user); }); if(!hasUer) { //storing the new user } else { //default } So my question is how to store a value returned by a promise or use a promise inside a if statement, and what I have done wrong. Thanks and Happy new year!!!