Answer the question
In order to leave comments, you need to log in
inversify-restify-utils empty context and body in controller?
I was trying to run inversify-restify-utils and ran into a problem. Request context and req.body variable are not defined.
@Controller('/users')
@injectable()
export class UsersController implements interfaces.Controller {
@Post('/')
createUser(req: restify.Request, res: restify.Response, next: restify.Next) {
console.log(req.body); // undefined
}
}
// to get query params in req.query
this.server.use(restify.acceptParser(this.server.acceptable));
// to get passed json in req.body
this.server.use(restify.bodyParser());
this.server.post('/test', (req, res, next) => {
console.log(req.body); // ok
next();
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question