1function firstFunction(_callback) {
2 // do some asynchronous work
3 // and when the asynchronous stuff is complete
4 const fs = require('fs');
5 let jsonData;
6 fs.readFile("industriesByCat.txt", 'utf8', function (err, data) {
7 if (err) throw err;
8 jsonData = JSON.parse(data);
9 console.log(jsonData);
10
11 //This is important for callback
12 _callback();
13 });
14
15}
16
17function secondFunction() {
18 // call first function and pass in a callback function which
19 // first function runs when it has completed
20 firstFunction(function () {
21 console.log('huzzah, I\'m done!');
22 });
23}
24secondFunction();
25