tadasajon
tadasajon

Reputation: 14846

Meteor.js - how can I receive POST data from another web app?

I have a Meteor app that currently polls another app for updates. I would like to stop the inefficient polling and have the other app just POST data to the meteor app when it's ready. How can I receive POST data in my meteor app?

Upvotes: 2

Views: 774

Answers (2)

Jankapunkt
Jankapunkt

Reputation: 8413

You can use the built in webapp package to receive and respond HTTP requests on the server side. It works without any additional packages (such as iron router, flow router etc.).

Upvotes: 2

Ryan Yeske
Ryan Yeske

Reputation: 456

If you are using Iron Router, you can setup a server route to handle the request:

if (Meteor.isServer) {
  Router.map(function () {
    this.route('serverRoute', {
      where: 'server',
      path: '/server',
      action: function() {
        if (this.request.method === 'POST')
          this.response.end("handling post request");
      }
    });
  });
}

Upvotes: 2

Related Questions