TypeError: undefined不是一个函数GET请求/数据库调用
TypeError: undefined is not a function GET request/db call
当使用node.js执行GET请求时,我得到一个TypeError。它看起来和我所有其他模块中的所有其他请求一样。在我创建的两个模块之间执行的代码中返回错误,所以我不确定发生了什么。
错误:TypeError: undefined is not a function
at Object.exports.getFollowingWatches (/Users/M/Desktop/Projects/BX-Server/modules/feed/feeddb.js:23:11)
at /Users/M/Desktop/Projects/BX-Server/modules/feed/index.js:55:5
at Layer.handle [as handle_request] (/Users/M/Desktop/Projects/BX-Server/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/M/Desktop/Projects/BX-Server/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/Users/M/Desktop/Projects/BX-Server/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/M/Desktop/Projects/BX-Server/node_modules/express/lib/router/layer.js:95:5)
at /Users/M/Desktop/Projects/BX-Server/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/Users/M/Desktop/Projects/BX-Server/node_modules/express/lib/router/index.js:330:12)
at next (/Users/M/Desktop/Projects/BX-Server/node_modules/express/lib/router/index.js:271:10)
at Function.handle (/Users/M/Desktop/Projects/BX-Server/node_modules/express/lib/router/index.js:176:3)
Get请求:
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 is the optimal max number? should do something elegant when this number is reached
res.status(400).send("max position number exceeded");
return;
}
db.getFollowingWatches(userId, position, function(feed) {
if (!feed) {
res.status(404).send("feed could not be loaded");
} else {
res.json(feed);
}
});
});
db call:
exports.getFollowingWatches = function(userId, position, callback) {
//@TODO: update interval time
var sql = "SELECT p.profilename AS watchname, p.idperson AS 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 from follow where isfollowing = ?) " +
"AND timewatched >= CURDATE() - INTERVAL 100 YEAR " +
"AND b.iscomplete = 0 " +
"LIMIT BY ?, ?";
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 but an error is returned before the if statement is hit back in the GET request
};
dbcommon.executestatement……正在执行,但在GET请求中执行if语句之前,错误被击中
我没有大写dbcommon.executeStatement中的S。这个问题现在解决了。编程,lol。
相关文章:
- $resource 'get' 函数如何在 AngularJS 中同步工作
- 调用$.get函数时JQuery中出现无效标签错误
- ajax上get函数内部的未定义错误
- 如何在多 Jquery Get 函数中等待
- 尝试循环访问数组并为每个数组添加一个 get 函数
- 使AJAX“get”函数同步/如何获得结果
- 为什么我不能从节点和 express.js 中的 app.get 函数中提取回调
- 无法访问 GET 函数之外的 var
- $.get 函数在 IE 中不调用
- 新手到jQuery和get函数
- 如何添加在调用 tinymce get 函数时触发的事件侦听器
- 将 JavaScript get 函数添加到 href
- get 函数数据报告空信息
- 我应该如何处理在多个页面上重复使用的ajax get函数
- jquery.get函数url参数
- 如何使用JQuery'发布动态JSON字符串;s get函数
- 在Else If语句中使用JQuery.get函数中的数据
- get函数不会从表单中动态创建的字段中获取数据
- 修改 jquery $.get 函数响应
- $.get函数不在Chrome中运行,但在IE和FireFox中运行