Send data from Server to Client in Meteor -


i want contents of web-page, processing on server side (to avoid running same origin security problems on client) , send result of client display.

i have written meteor method data as:

meteor.methods(     {         geturl: function(url_l){             console.log("request: "+url_l)              //  var httpresult = http.get(url_l){}             //  return httpresult.data.response;              var response = http.get(url_l)             var status = response.statuscode             var content = response.content              console.log(status)             console.log(content)              return content         }     }); 

the return unfortunately doesn't work.

short of making database entries cant think of way of passing data client. 'undefined' on return.

update

i tried async callback:

meteor.methods(     {         geturl: function(url_l){                 console.log("request: "+url_l)             //  var httpresult = http.get(url_l){}             //   return httpresult.data.response;             var response = http.get(url_l, function(err,res){                     if(err)                         console.log(err)                          var status = res.statuscode                 var content = res.content                console.log(status)               console.log(content)               return content              });               }     }); 

just clarifying question - regardless of if use sync or async http callback, when this:

//autofetch = meteor.call("geturl",url_l) console.log(a) 

i undefined.

the url entered is: http://shaunak.de siteace.js:115 undefined 

are sure you're request done before returning it?

usually have set callback http.get sure request done:

from doc:

http.get(url, [calloptions], [asynccallback]) 

try:

   geturl: function(url_l){         console.log("request: "+url_l)          http.get(url_l, function(err, response){             if(err)                 console.log(err);             var status = response.statuscode             var content = response.content              console.log(status)             console.log(content)             return content         });     } 

Comments