In my javascript code, I have three functions - one that establishes a connection to my mongo database, another that spawns a child process and passes the database value to the phantomjs child process, and a third function that retrieves and processes the data returned by phantomjs.
I am looking for a way to make these functions run synchronously. Is there a specific method to achieve this?
Here is what I aim to accomplish:
function connectdb() {
// Connects to MongoDB and retrieves email values from the database
// Writes the emails to an external .txt file as well
}
function create_child() {
// Spawns a child PhantomJS process using an external .js Phantom file
// Retrieves data from the child process
}
function process_data() {
// Processes the data received from create_child()
}
I would like these functions to be executed in sequence: connectdb(), then create_child(), and finally process_data().