I'm runningif-else
block of code as shown below :
if (condition){
var id = data1.id ;
}
else
var id = data2.id ;
And i'm using this id
for some other operation as :
if (id==some value){
do something ;
}
The above operation is performed when a user registers to the application or if the already logged in user wants views a certain page. Since, node.js is asynchronous, when the user register and the result is stored in database, the id
field is undefined and in the 2ndif condition
the value of id
becomes undefined. But if the user is already logged in this works perfectly as there is not much time consuming operation done. So can anyone suggest me some way to resolve the above issue. Any help or guidance will be highly appreciated.