meteor - creating proxy url with meteorjs -


i wondering how might achieve following using ironrouter in meteorjs:

app.route("/api/tts").get(function(req,res){   res.type('audio/mpeg');    var text = req.query.q;   var request = require('request');   var url = "https://translate.google.pl/translate_tts?ie=utf-8&q=" + text + "&tl=en&total=1&idx=0&client=t&prev=input";   request.get(url).pipe(res); }); 

if have iron:router installed already, can. need install request using meteorhacks:npm.

then write:

router.route("/api/tts", function () {   // nodejs request object   var req = this.request;   // nodejs response object   var res = this.response;   res.type('audio/mpeg');    var text = req.query.q;   var request = meteor.npmrequire('request');   var url = "https://translate.google.pl/translate_tts?ie=utf-8&q=" + text + "&tl=en&total=1&idx=0&client=t&prev=input";   request.get(url).pipe(res); }, { where: 'server' }); 

let me know if works.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -