I'm having Javascript problem to wait a function done before the below line is called. The previous function is including the Javascript MYSQL Queries calls (one of the library of node.js). Then it will be looks like:
function first() {
/**
* a lot processes to execute
* including Asynchronous processes
* like running Queries using Javascript MYSQL Library from node.js
*/
console.log("I am the first one!");
}
first();
console.log("I am the second one!");
Then when i execute this, it happening like:
I am second one!
I am first one!
How do i make them run by keeping the queue order?
NOTE: Now for everyone who confusing the question, please jump/follow my newly created question again:
Everyone please follow/jump into this new question: Node.js MYSQL to detect the INSERT/UPDATE completeness of a Query?
Pass a callback to the 2nd function to the call to the 1st function. At the end of the 1st function, invoke theh callback:
function one(parm, callback) {
// do something
callback();
}
function two() {
// do something else
}
one("my parm", two);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With