POST-data with meteorhacks:picker


Trying to break away from iron:router but I’m struggling with some basic concepts.

I’m trying to recieve POST-data from Mailgun (incoming mail), this is my code:

var bodyParser = Meteor.npmRequire('body-parser'); 
Picker.middleware(bodyParser.urlencoded({ extended: false }));

var post = Picker.filter(function(req, res) {
  return req.method == "POST";

post.route('/post', function(params, req, res, next) {
  console.log(params);   // { query: {} }
  console.log(; // undefined
  console.log(req.body); // {}

How can I solve this?

If I make a on my own with data instead of params it works, but I can’t control what Mailgun sends me

It works try doing this. It works.

curl -d "aa=10&bb-20" http://localhost:3000/post

Params is for when you are using express like paths for the route and to get query params.

Thanks @arunoda, that works. I’ll ask Mailgun how they are sending their data. Cheers

1 Like

The HTTP Post will be encoded as application/x-www-form-urlencoded for most messages, and multipart/form-data if there’s an attachment included.

This is the reply I got, do I have to add anything else?

They seems like sending a URL encoded message. try to inspect what they send with a service like this:

Were you able to find a solution to this @benjick? It seems like I need to have Meteor wait for a stream to finish before the full results are ready to use. I’m certainly seeing the same issue you pointed out.

bodyParser does not handle form-data, try something like

1 Like


Were you able to get Mailgun incoming working?

I wonder whether Meteor 1.3 makes this easier now that npm packages are easier to install (but on the flipside, 1.3 is so new that there are still limited tutorials for noobs like me!)

did you solve this in the end? how you parsing the multipart once you receiving it with Picker?


This worked for me:

Picker.route('/yourapi', function(params, req, res, next) {
  let body = ''
  req.on('data', Meteor.bindEnvironment((data) => {
    body += data;
  })).on('end', function() {
      // do something here
     res.end('api result');

This is sort of working, it’s giving me what looks like a buffer or base64 string or something. But it’s not easily parsible