代码拉取完成,页面将自动刷新
Pretty query middleware for koa.
Koa
uses queryString
to parse the GET
parameter by default, but the parsed arguments are string
.
Koa-query-pretty
can be converted to concrete types like int
, float
, boolean
, null
, undefined
.
yarn add koa-query-pretty
Support node.js v7.6+
const Koa = require('koa');
const queryPretty = require('koa-query-pretty');
const app = new Koa();
app.use(queryPretty());
/home?id=1&name=jack&enable=true&money=2.5&hobby=1&hobby=2
result
ctx.query:
{
"id": 1,
"name": "jack",
"enable": true,
"money": 2.5,
"hobby": [
1,
2
]
}
Overwrite the ctx.query
parameter, default true
, otherwise use ctx.prettyQuery
to get
app.use(queryPretty({ override: false }));
app.use(async (ctx, next) => {
console.log(ctx.prettyQuery);
await next();
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。