Body content in post request is undefined in loopback

281 views
Skip to first unread message

JR

unread,
Mar 1, 2017, 1:57:21 AM3/1/17
to loopb...@googlegroups.com
Hai,
    I have tried the user login API using User.login in routes.js file in loopback. The post request body content is always undefined but the headers and query is working fine. What may be the reason? 

Raymond Feng

unread,
Mar 1, 2017, 12:26:54 PM3/1/17
to loopb...@googlegroups.com
Do you use a regular express route to handle the request? If so, you probably need to set up bodyParser middleware for your path. LoopBack only captures /api/… routes.


On Feb 28, 2017, at 10:57 PM, JR <ravi...@gmail.com> wrote:

Hai,
    I have tried the user login API using User.login in routes.js file in loopback. The post request body content is always undefined but the headers and query is working fine. What may be the reason? 

--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/b6176786-c93b-463d-9e45-06e2b6e03e99%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

JR

unread,
Mar 6, 2017, 5:46:23 AM3/6/17
to LoopbackJS
No. I have used only loopback. I was able create a user but couldn't able to login. when I call the 0.0.0.0:3000/api/users/login as POST request I am getting the following error. Though I have passed the email and password in body.

{"error":{"statusCode":400,"name":"Error","message":"username or email is required","code":"USERNAME_EMAIL_REQUIRED"}}

Ankush Pandey

unread,
Oct 14, 2017, 6:16:35 PM10/14/17
to LoopbackJS
Same here. JR, did you find a solution to this issue?

Stanislav Maslov

unread,
Apr 25, 2018, 7:58:15 AM4/25/18
to LoopbackJS
this answer helped me

среда, 1 марта 2017 г., 19:26:54 UTC+2 пользователь Raymond Feng написал:
Reply all
Reply to author
Forward
0 new messages