Open urossmolnik opened 9 years ago
I think you have a scope issue with this. I'll try:
Router.map(function() {
var self = this;
this.route('/echo/:msg', {
name: 'echo',
where: 'server',
action: function() {
this.response.writeHead(200, {'Content-Type': 'text/plain'});
this.response.end(self.params.msg || '');
}
});
});
Not working either. self.params
is undefined
for given example.
Give a try with the route method instead of map:
Router.route('/echo/:msg', function() {
this.response.writeHead(200, {'Content-Type': 'text/plain'});
this.response.end(this.params.msg || '');
}, {
name: 'echo',
where: 'server'
});
params property on route callback is not se correctly for server routes?
For the example below, when going to
http://localhost:3000/echo/asdf
this.params is set to[ 'echo/asdf', hash: null, query: {} ]
.As understood from documentation params should be something like
{ msg: 'asdf', hash: null, query: {} }
Example:
I am using iron:router@1.0.7