Create Users Route /api/users/ [POST]
OliverTr54 opened this issue · 3 comments
Hey guys,
I downloaded this package and I was trying to create a user sending POST args to the route
localhost:3000/api/users
with the following body arguments via POSTMAN:
{
"username": "abc123",
"email":"abc@yzx.com",
"password": "1234567890"
}
...but I always receive a 400 - with no data submitted. What am I'm doing wrong? Postman issue or a route error?
Just for your information - the route localhost:3000/api/articles
[GET] works fine receiving a 200 code and some sample data pushed to the database directly.
Thanks in advance,
Oliver
Hi Oliver,
the payload structure is wrong. You can see the realworld API specs herer https://github.com/gothinkster/realworld/tree/master/api#registration and also find the payload is nested in a "user" property in the code here https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/user/user.controller.ts#L35
If the user
value in the @body
decorator parameter makes the payload nested.
I tried several things and I believe I did this as well, but let me verify this later at home. I will get back to you or close the issue if it'll work.
Thanks!
As promised - I test the package again with your hints and the import file for POSTMAN and all seems to work fine. Sorry about this. I should more carefully read the specs next time.
Great example - thanks!