diff --git a/index.js b/index.js index 70414ac..05477ad 100644 --- a/index.js +++ b/index.js @@ -127,12 +127,21 @@ server.post('/addmonth_v', bodyParser.json(), function (req, res) { var d = 1; //counts cycles in scenario key values which are arrays var args = []; var path = './route_sql/addmonth_vd.sql'; + + fs.readFile(path, 'utf8', function(err, data){ + if (!err){ + callback(data); + } else { + console.log("fatal error pulling sql file") + callback(err); + } + }); var callback = function(arg){ sql = arg; //buile where clause expression ({ c, w, d } = build_where(req, c, w, d, args)); - + if (c == 1) { res.send("no body was sent"); return; @@ -151,15 +160,6 @@ server.post('/addmonth_v', bodyParser.json(), function (req, res) { console.log(sql) Postgres.FirstRow(sql,[],res) } - - fs.readFile(path, 'utf8', function(err, data){ - if (!err){ - callback(data); - } else { - console.log("fatal error pulling sql file") - callback(err); - } - }); }) server.post('/addmonth_vp', bodyParser.json(), function (req, res) {