【发布时间】:2020-11-29 15:45:43
【问题描述】:
我正在使用 node.js + express + typescript,我想获取 GET 参数。到目前为止我有这个
app.get('/top_games', (req, res) => {
const page = req.route.page;
const offset = req.route.offset;
const game_data = DAO_GAME.GetTopGuilds(100, 0);
res.send({
total : game_data[0],
data : game_data[1]
});
});
但是 eslint 抱怨
const page = req.route.page;
const offset = req.route.offset;
说
Unsafe assignment of an any value.eslint@typescript-eslint/no-unsafe-assignment
Unsafe member access .page on an any value.eslint@typescript-eslint/no-unsafe-member-access
我该如何解决这个问题?
【问题讨论】:
-
req.params 给你什么? app.get('/user/:id', function (req, res) { res.send('user ' + req.params.id) })
-
req.paramsget me{},数据在req.query
标签: node.js typescript express eslint