express 路由问题

feixuyue 2015-06-15 11:18:19
router
module.exports = function (app) {
app.use("/api/query", function (req, res) {
if (req.query.reqP) {
var where = " Where " + req.query.reqP;
}
else {
where = "";
}


路由分发
app.use(function (req, res) {
if (req.path.indexOf('/api/') >= 0) {
Query(app);
} else { //angular启动页
res.sendFile(path.join(__dirname, './views', 'index1.html'));
}
});


客户端请求
  $http.get('/api/query', { params: pms })
.success(function (data, status, headers, config) {
console.log("query project success---------");

for (var p in data) {
var pi = {
name: p,
fList: [],
tList: []
};
$scope.pList.push({ name: p });
}
})
.error(function (data, status, headers, config) {
console.log("query project fail---------");
});


进入到router函数名,然后直接跳过 app.use("/api/query", function (req, res) 函数,不执行,客户端返回超时,求帮助
...全文
107 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

87,955

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧