routing-controllers icon indicating copy to clipboard operation
routing-controllers copied to clipboard

@BodyParam doesn't work without explicitly using the 'body-parser' module

Open shurmanidze opened this issue 7 years ago • 3 comments

I have to use this:

    const app = express();
    app.use(bodyParser.urlencoded());

    useExpressServer(app, {
        controllers: [
          ...
        ],
        cors: true,
    });

instead of this:

    createExpressServer(app, {
        controllers: [
          ...
        ],
        cors: true,
    });

The controller and action:

@Service()
@JsonController('/auth')
export class AuthController {
    constructor(
        @InjectRepository(User)
        private userRepository: Repository<User>,
    ) {
    }

    @Post('/form/register')
    public async register(
        @BodyParam('email') email: string,
        @BodyParam('password') password: string,
    ): Promise<User> {
        ...
    }
}

shurmanidze avatar Nov 23 '19 19:11 shurmanidze

Dammmn. This is depressing. I've been stuck with this problem for a few hours. Thank you so much!

exwyezed avatar Nov 30 '19 20:11 exwyezed

Stale issue message

github-actions[bot] avatar Feb 05 '20 00:02 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Dec 13 '20 00:12 github-actions[bot]