Skip to content

Instantly share code, notes, and snippets.

@shinecita
Last active March 9, 2017 12:52
Show Gist options
  • Save shinecita/4595263 to your computer and use it in GitHub Desktop.
Save shinecita/4595263 to your computer and use it in GitHub Desktop.
not sure how to handle the redirect response in the resource
// Gets user avatar url
router.get('/:userId/avatar', function(req, res) {
console.log("User", req.user.pictureUrl);
if (req.user.pictureUrl) {
console.log("redirecting avatar")
res.redirect(req.user.pictureUrl)
} else {
console.log("redirecting default")
res.redirect('/img/userProfileAvatar.png')
}
})
<div class="span6" id="activities">
<h3 class="span2">Activity</h3>
{{activities[0].actor.avatar()}}
User.prototype.avatar = function() {
console.log(this);
this.avatar = User.query({prefix: 'users/'+ this._id +'/avatar'}, function (avatar){
console.log(this.avatar);
return avatar;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment