Reputation: 1981
I have a post data in the format below
authInfo={"user":"1","password":"a"}
How do I get the key ie authInfo. I am stuck here! req.query
did not work out. Any help will be much appreciated.
Upvotes: 1
Views: 508
Reputation: 14003
var authInfo = {"user":"1","password":"a"}
var user = authInfo.user
var pass = authInfo.password
// user = 1 , pass = a
Upvotes: 0
Reputation: 63139
Data transmitted via POST could be found in req.body
.
For your example:
req.body.authInfo
Also: You need a data parser enabled, otherwise the Post data will not be decoded. I assume you use express, so you would need app.use(express.bodyParser())
.
Upvotes: 2