Building a restful API -- I'm stuck on /api/receive

Howdy yall,

I’m using FlowRouter.

I have a url /api/receive

How do I capture the data, and spit back out some XML? Is this a “server side render?”

Update: Okay what I really need is the ability to produce a CLEAN output… currently that URL has a bunch of garbage from Meteor… This is where I’m most confused.

Screenshot

I need all this stuff to go away, so I can output a nice clean html file…

You will have to give us a bit more to give a good example. How does your serverside code look like? By the looks of it, you are not using any serverside rendering. This is just Meteor giving you all of its clientside stuff. Try this on the serverside:

import { JsonRoutes } from 'meteor/simple:json-routes';

JsonRoutes.add('get', '/api/receive', async (req, res) => {

  // Do some API stuff
  const content = '<xml>stuff thingy</xml>';

  JsonRoutes.setResponseHeaders({
    'Content-type': 'text/xml',
  });
  res.end(content);
});

It uses Meteor simple:json-routes to create an endpoint.

However, you can also simply return XML using a meteor method if your goals is to get it to your app’s clientside?

Meteor.methods({
  receive() {
    return '<xml>Stuff thingy</xml>';
  },
});
1 Like

Ahhhhh you rock dude. This exactly worked in like 30 seconds vs the 8 hours I’ve been looking.

THANK YOU. <3

1 Like