diff --git a/app/routes/research.js b/app/routes/research.js index 0645487..c3ae59d 100644 --- a/app/routes/research.js +++ b/app/routes/research.js @@ -1,5 +1,5 @@ const ResearchDAO = require("../data/research-dao").ResearchDAO; -const needle = require('needle'); +const needle = require("needle"); const { environmentalScripts } = require("../../config/config"); @@ -13,14 +13,17 @@ function ResearchHandler(db) { if (req.query.symbol) { const url = req.query.url + req.query.symbol; - return needle.get(url, (error, newResponse) => { - if (!error && newResponse.statusCode == 200) + return needle.get(url, (error, newResponse, body) => { + if (!error && newResponse.statusCode === 200) { res.writeHead(200, { - 'Content-Type': 'text/html' + "Content-Type": "text/html" }); - res.write('

The following is the stock information you requested.

\n\n'); - res.write('\n\n'); - res.write(newResponse.body); + } + res.write("

The following is the stock information you requested.

\n\n"); + res.write("\n\n"); + if (body) { + res.write(body); + } return res.end(); }); }