I have the following function:
async function updateData() {
return firebase.database().ref(varurl3).child('UserCount/count').once('value').then(function(snapshot) {
var username = snapshot.val();
var username2 = username + 1;
return firebase.database().ref(varurl3).child('Users').child(username2).child('User').once('value').then(function(snapshot) {
var username3 = snapshot.val();
if (username3 != null) {
await Sleep(3000);
}
});
});
}
timeupdater = setInterval(updateData, 100);
I have marked my function as "async" but the following error message still appears: "Uncaught SyntaxError: await is only valid in async functions and async generators". Can anyone tell me how I can solve this problem? I would appreciate a helpful answer.