nodeJs callbacks simple example
can any one give me a a simple example of nodeJs callbacks, I have already searched for the same on many websites but not able to understand it properly, Please give me a simple example.
can any one give me a a simple example of nodeJs callbacks, I have already searched for the same on many websites but not able to understand it properly, Please give me a simple example.
I’m new to JavaScript and to node.js. I want to loop through a directory and add all file stat (not other directories) to an array. As you see below there is a problem with my code since the callback will probably get called after the for loop has finished so using the “i”-variable in the callback method will not work. But how should the code look so that the below snippet works? Does it have something to do with closures?
I need to invoke aws lambda from another lambda asynchronously. i have a working code for synchronous calls.
I am writing code for getting data.
First I call **getsomedata**
function to get data and inside getsomedata function I am calling another function getRandomdata to get data and returning it back to the previous function but it is returning undefined
. But in getRandomdata
data could be seen in console.log
.
Do I need to use callbacks
?