How to consume JSON POST data

46 views
Skip to first unread message

Merlin Gaillard

unread,
Jun 30, 2014, 5:27:09 AM6/30/14
to ged...@googlegroups.com
Hi,

Is there a possibility to consume a post body instead of using URL parameters?

For now the request's body is completely ignored and I cannot find a way to parse it...
I would like to be able to post multiple records at once.

Regards,
Merlin

Ben Ng

unread,
Jun 30, 2014, 10:16:28 AM6/30/14
to ged...@googlegroups.com
You need to parse it yourself using the req stream.

Ben Ng


--
The official community discussion group.
website: geddyjs.org, source: https://github.com/mde/geddy, group: https://groups.google.com/d/forum/geddyjs?hl=en
---
You received this message because you are subscribed to the Google Groups "GeddyJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geddyjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Merlin

unread,
Jun 30, 2014, 10:30:01 AM6/30/14
to ged...@googlegroups.com
Yes, I was trying to look at the req stream but I am unable to inspect the body, I am only able to inspect the headers...

Ben Ng

unread,
Jun 30, 2014, 12:22:12 PM6/30/14
to ged...@googlegroups.com
The request stream is something like req.request. Geddy wraps it. I dont think that there is a body to inspect. You just pipe it into something like concat-stream or formidable.

Ben Ng

Matthew Eernisse

unread,
Jun 30, 2014, 12:54:45 PM6/30/14
to ged...@googlegroups.com
Since Node 0.10 we no longer wrap the request. Geddy parses the body for POST/PUT form and JSON input:

https://github.com/geddy/geddy/blob/master/lib/controller/init.js#L37

I notice that we're silently squelching JSON parse errors there, which is clearly not the right thing to do. I've added a GH Issue for this: https://github.com/geddy/geddy/issues/616



Reply all
Reply to author
Forward
0 new messages