박지환

Update get data initially

......@@ -31,7 +31,7 @@ var tempArr = [];
app.set("views", __dirname + "/views");
app.set("view engine", "ejs");
app.get("/", function (req, res) {
function init() {
request.get(requestUrl, (err, res, body) => {
if (err) {
console.log("err => " + err);
......@@ -84,6 +84,10 @@ app.get("/", function (req, res) {
}
}
});
}
app.get("/", function (req, res) {
init();
// Send data from nodejs to ejs
res.render("data.ejs", { data: tempArr }, function (err, html) {
if (err) {
......@@ -95,5 +99,7 @@ app.get("/", function (req, res) {
res.sendFile(__dirname + "/views/data.ejs");
});
init();
const port = 8080;
app.listen(port, () => console.log("Listening on port " + port));
......