http://localhost:3000/endpoint?id=83结果为 404(未找到)。所有其他路线都按预期工作。我在这里错过了什么吗?
router
.get('/', function *(next) {
yield this.render('index.ejs', {
title: 'title set on the server'
});
})
.get('/endpoint:id', function *(next) {
console.log('/endpoint:id');
console.log(this.params);
this.body = 'Endpoint return';
})
koa-router 参数文档
//Named route parameters are captured and added to ctx.params.
router.get('/:category/:title', function *(next) {
console.log(this.params);
// => { category: 'programming', title: 'how-to-node' }
});
角度控制器中的请求:
$http.get('/endpoint', {params: { id: 223 }})
.then(
function(response){
var respnse = response.data;
console.log(response);
}
);