I don’t quite understand how this works, the documentation doesn’t really explain what’s going on with recieving the data.
In my js (separate folder from meteor server) I’ve added:
const sendData = { url: www.google.com, key: 12345 }; const sendDataString = JSON.stringify(sendData); const xhr = new XMLHttpRequest(); xhr.open("POST", 'http://localhost:3000/request', true); xhr.setRequestHeader("Content-type", "application/json"); xhr.send(sendDataString);
And then in the meteor server (which is on localhost:3000)
WebApp.connectHandlers.use('/request', (req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*')
console.log(GET DATA SOMEHOW);
console.log(bodyParser.json(req)) //trying some random
res.writeHead(200);
res.end(JSON.stringify({ status: 'ok' }));
});