0

I am using MeteorJS & PhantomJS almost the same as the example/solution in this thread.

I am now trying to pass Strings from the PhantomJS script to MeteorJS where I intend to store it to a Mongo collection.

My question is: how do I pass variables such as Strings (or an Array of strings) from PhantomJS to MeteorJS ?

I am currently doing

console.log('uniqueMarker ', myString); 

and then 'capturing' the console.log in MeteorJS via stdout data but this doesn't seem to be a reliable approach.

Community
  • 1
  • 1
rrrrrraul
  • 121
  • 2
  • 7
  • Why isn't it reliable? What's the problem? – Artjom B. Jun 29 '15 at 07:21
  • @ArtjomB. I am trying to pass in to Meteor approx 200 strings, when I console.log from PhantomJS so as to capture in Meteor via `command.stdout.on('data', function (data) { //do something with data });` I don't always get back 200 strings, I am missing anywhere from 20 to 50 strings. Intermittent success. – rrrrrraul Jun 29 '15 at 07:35
  • Either that has something to do with how you print and parse those strings (think about line endings) or child_process simply loses some updates. You can also check whether you really should get 200 messages back and not less. – Artjom B. Jun 29 '15 at 07:42

1 Answers1

0

you can pass variables as json post(serialized) from PhantomJS to MeteorJS (open new iron:router handler for this call) my example is with CasperJS, but it is pretty much the same:

var updateInfo = JSON.stringify( config.paymentsUpdateOnError );
casper.log('paymentsUpdateOnError: ' + updateInfo, 'debug');
casper.thenOpen( config.PaymentsURL, {
        method: 'POST',
        data: updateInfo,
        headers: {
            'Content-Type': 'application/json',
            "Accept": "application/json"
        }
}, function(){
    return casper.exit(1);
});

Good luck