@aleksey-popryaduhin

Inversify-restify-utils пустой контекст и body в контроллере?

Я пытался запустить inversify-restify-utils и столкнулся с проблемой. Request context и переменная req.body не определены.

@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
  }
}


Мой server.ts:

// 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();
});


Есть идеи?
  • Вопрос задан
  • 97 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы