我有两个端点:Koa2同一路线不同PARAMS
通过ID得到所有用户
http.get(API_URL + "users/" + id)
GET通过用户名的所有用户
http.get(API_URL + "users/" + username)
我可以发送不同的参数在同一条路线上:
router.get("https://stackoverflow.com/users/:id", async ctx => {
//ctx.request.param is id
//do something
});
router.get("https://stackoverflow.com/users/:username", async ctx => {
//ctx.request.param is username
//do something
});
感谢您的帮助!