Unable to parse HTTP body content inside JSONROUTE api


#1

Hi all,
I’m trying to implement rest api using JSONROUTES, on server side and I can send the response and see the result on the client side. The issue I’m facing when I send any data to server using api it is receiving on the server side but I can not parse it(body). If anyone known to this. Please help me.

JsonRoutes.add(“post”, “/posts_api/”, function (req, res, next) {
var options=req.body;
console.log(options) //got the entire content { data1: ‘20\na=20\ndata2={in:{a:20}’ }
console.log(req.body.data1 )//undefined

JsonRoutes.sendResult(res, {
data: Meteor.users.find().fetch()
});
});

data is passing using postman, this is my apit: http://192.168.1.153:3000/posts_api
data1=20
a=20
I would like to get the data1 filed in my function.


#2

Thank you who all read the above question. Unfortunately I didn’t get the answer for the above. But I got another package which fulfilled my need. " meteor add nimble:restivus" helped to get the body content easily.
If anyone wanted to use external api for their app, my recommedation is nimble restivus