How to call callback function in within callback function in node.js
Call back functions in node js are no different than those in javascript. This is one way you can call it.
function someFunction(callback){
callback(params);
}
the call back function can be defined as any normal function.For example
function random(number){
return Math.random()};
the function someFunction can now be called as
someFunction(random);
That's it.The important thing to understand here is that node js is still javascript.So everything trick that works in javascript will work in node js.
just pass it to other functions
also notice that JS is lexical scoping
so make sure ur callback parameter in the scope or outer scope --> What is lexical scope?