84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
我想设计一个路由,当有id 参数时查询一个,没有id参数时查询全部
router.get('/role/:id?', role.find);
而没有id参数时候,查询全部我还想做分页,于是我这样做
router.get('/role/:id?/:page?/:count?', role.find);
然后单元测试类似这样请求
get('/role//2/2')
好吧是错的
不知道应该怎么改。。。
学习是最好的投资!
router.get('/role/:page?/:count?', role.find);
I didn’t think well of the question just now. . .
Use two optional parameters directly, and then judge the number of parameters to determine whether to query all or pagination.
I didn’t think well of the question just now. . .
Use two optional parameters directly, and then judge the number of parameters to determine whether to query all or pagination.