I'm new in Meteor.js and have a basic question. I want to render a template with data from server side route with iron-router module. I used where: 'server' in my route obtion (from this link) but render function ( this.render() ) not fired.
I successfully done this by using NodeJS Request and Response object (as above example) but I want to pass data to template and render the template from server.
This is my route code:
Router.route('/movie/title', function () {
var request = Meteor.npmRequire('request');
var future = new (Npm.require('fibers/future'))();
request('http://www.google.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
future.return(body);
}
else {
future.throw(error);
}
})
var myResult = future.wait();
console.log(myResult);
this.render('test', {
data: { result: myResult }
});
}, { where: 'server' });
And this is my template code:
<head>
<title>Search your favorite movie</title>
</head>
<body>
<h1>Welcome to Meteor!</h1>
{{> hello}}
</body>
<template name="hello">
<button>Click Me</button>
<p>You've pressed the button {{counter}} times.</p>
</template>
<template name="test">
{{result}}
</template>
Please guide me.