【发布时间】:2017-02-25 12:06:27
【问题描述】:
我正在使用带有 express 的节点。
我有两个rest api,api之间的区别只是数据库表而已。
API - 1 http://localhost/test1
API - 2 http://localhost/test2
都是post方法,
router.post('test1', findAll);
router.post('test2', findAll);
function findAll(req, res){
//Here test1 api result get from different db table.
//Here test2 api result get from different db table.
How can I sent the db table name in parameters?
//Here have logic in db and return results.
res.send(spec.resp);
}
注意:我需要对两个 api 使用相同的函数,但表名会改变。
【问题讨论】:
标签: javascript node.js api express callback