Closed nassirdreffy closed 5 years ago
Hi nassirdreffy, please check out this example: https://github.com/jkyberneees/ana/blob/master/demos/basic-service-params.js
I will later check if this is an issue with anumargak router. For now please just try out with default router, like this:
const service = require('restana')({})
service.get('/user/:id', (req, res) => {
res.send(req.params.id)
})
service.start()
Regards.
Of course you can still override the server config if you need it:
const service = require('restana')({
server
})
thank you very much, it works !!
so is it maybe a conflict with anumargak router . ://
I will later check if this is an issue with anumargak router.
Do you have an idea why it might be=?
Regards
I will properly check and let you know. Thanks.
I can reproduce:
service.get('/name/:id', (req, res) => {
res.send('Hello ' + req.params.id)
})
req.params is null once using anumargak
router. It suppose to be signature compatible with find-my-way
router for params parsing, but it looks like not being the case. More details will follow...
Hi @nassirdreffy, please consider that when using anumargak router, request params are accessible via:
req._path.params
Although I would strongly suggest to use the default find-my-way
router.
Regards, Rolando
ERROR MESSAGE: {"errClass":"TypeError","code":500,"message":"Cannot read property 'id' of undefined"}
const bp = require('body-parser') const anumargak = require('anumargak') const routerFactory = (options) => { return anumargak(options)}
const service = require('restana')({ server, routerFactory});
service.get('/user/:id', (req, res) => { res.send(req.params.id) })
service.start(3000)
I don't have any idea what's going on . Please help