Hi All,
I am working on creating user profiles within my app and have found this to be not so easy. First off, I am trying to create the right route to my profile page using iron router. I followed the steps here:
Is there something off with my route?
My router.js is:
Router.route(‘profile/:username’,{
name:“profile”,
controller:“ProfileController”,
template: ‘profile’
});
I created a Profile Controller:
ProfileController=RouteController.extend({
template:“profile”,
waitOn:function(){
return Meteor.subscribe(“userProfile”,this.params.username);
},
data:function(){
var username=this.params.username;
return Meteor.users.findOne({username:username});
}
});
Basic HTML profile template:
<div class="container">
<h3>{{username}}</h3><br>
<h4>Will be adding more stuff here like Bio, Photo next</h4><br>
What would be a way to have the route correctly pass the username? Is this done in profile controller or would you create data:function and add parameter username that way instead?
I created a separate link/file for linking in the navigation which does not lead to this profile route:
<template name="_loginButtonsAdditionalLoggedInDropdownActions"> <button class="btn btn-default btn-block" id="login-buttons-edit-profile">Edit profile</button> </template>
Template._loginButtonsLoggedInDropdown.events({
‘click #login-buttons-edit-profile’: function(event) {
Router.go(‘profile’);
}
});
Checking in console I get this error:
Uncaught error: missing required parameters on path “/profile/:username”. The missing params are: [“username”]. The params object passed in was: undefined.
Thanks for any help!