I am trying to get the uid value returned successfully by the following function, and use it as a variable outside of the function as a constant or variable. Below is my code. I am new to node js. please help me. thank you in advance
admin.auth().getUserByEmail(email)
.then(function(userRecord) {
console.log('Successfully fetched user data:', userRecord.toJSON());
var userdata = userRecord.toJSON();
var uid = userdata.uid;
console.log('uid', uid);
return uid;
});