router.get("/stocks/authed/:symbol", function (req, res, next) {
req.db
.from("stocks")
.select("*")
.modify(function(queryBuilder) {
if (req.query.from && req.query.to) {
queryBuilder.whereBetween('timestamp',[`%${req.query.from}%`,`%${req.query.to}%`]);
}
})
.where("symbol", "=", req.params.symbol)
.then((rows) => {
res.json({ Error: false, Message: "Success", Cities: rows })
})
.catch((err) => {
console.log(err)
res.json({ Error: true, Message: "Error in MySQL query" })
})
})
这是我现在得到的代码,网址是 http://localhost:3000/stocks/authed/AAL?from=2020-03-15T00%3A00%3A00.000Z&to=2020-03-20T00% 3A00%3A00.000Z
为了允许中间人正确读取网址,我认为我需要使用 decodeuricomponent 解码网址
我该怎么做?我试过包围%${req.query.from}%,%${req.query.to}%但没有奏效......