const express = require("express"); const app = express(); const request = require('request'); app.listen(3002, function () { console.log("Server running on port 3002"); }); app.get("/getUserRepository", function (req, res, next) { var fs = require("fs"), path = require("path"), rootDir = process.argv.length > 2 ? process.argv[2] : process.cwd() userListArray = []; filePath = path.join(rootDir, "userList.txt"); console.log("before readFile"); fs.readFile(filePath, {encoding: "UTF8"}, function (err, templateResponse) { userListArray = templateResponse.split(","); console.log("readFile completion"); }); console.log("after readFile"); });