javascript - TypeError: undefined is not a function GET request/db call -
i getting typeerror when using node.js execute request. looks same other requests in other modules. error being returned in code executed between 2 created modules, i'm not sure what's going on.
error:
typeerror: undefined not function @ object.exports.getfollowingwatches (/users/m/desktop/projects/bx-server/modules/feed/feeddb.js:23:11) @ /users/m/desktop/projects/bx-server/modules/feed/index.js:55:5 @ layer.handle [as handle_request] (/users/m/desktop/projects/bx-server/node_modules/express/lib/router/layer.js:95:5) @ next (/users/m/desktop/projects/bx-server/node_modules/express/lib/router/route.js:131:13) @ route.dispatch (/users/m/desktop/projects/bx-server/node_modules/express/lib/router/route.js:112:3) @ layer.handle [as handle_request] (/users/m/desktop/projects/bx-server/node_modules/express/lib/router/layer.js:95:5) @ /users/m/desktop/projects/bx-server/node_modules/express/lib/router/index.js:277:22 @ function.process_params (/users/m/desktop/projects/bx-server/node_modules/express/lib/router/index.js:330:12) @ next (/users/m/desktop/projects/bx-server/node_modules/express/lib/router/index.js:271:10) @ function.handle (/users/m/desktop/projects/bx-server/node_modules/express/lib/router/index.js:176:3)
get request:
router.get("/getfollowingwatches", function(req, res, callback) { var userid = req.query.userid; var position = req.query.pos; if ((!(userid >= 1 && userid <= 9223372036854775807)) || (userid == undefined)) { //max signed res.status(400).send("userid invalid"); return; } if (!(position >= 0 && position <= 100000)) { //what optimal max number? should elegant when number reached res.status(400).send("max position number exceeded"); return; } db.getfollowingwatches(userid, position, function(feed) { if (!feed) { res.status(404).send("feed not loaded"); } else { res.json(feed); } }); });
db call:
exports.getfollowingwatches = function(userid, position, callback) { //@todo: update interval time var sql = "select p.profilename watchname, p.idperson watchid, b.idbounty, b.description, b.idcreatedfor, b.contenttype " + "from bounty b " + "inner join watch w on b.idbounty = w.idbounty " + "inner join person p on p.idperson = w.idperson " + "where w.idperson in (select beingfollowed follow isfollowing = ?) " + "and timewatched >= curdate() - interval 100 year " + "and b.iscomplete = 0 " + "limit ?, ?"; var inserts = [userid, parseint(position), 20]; sql = mysql.format(sql, inserts); console.log("getfollowingwatches db function running... " + sql); dbcommon.executestatement(pool, sql, callback); //this line executes error returned before if statement hit in request };
dbcommon.executestatement... being executed before if statement can executed in request, error hit
i didn't capitalise s in dbcommon.executestatement. solved now. programming, lol.
Comments
Post a Comment