Last active
March 9, 2017 12:52
-
-
Save shinecita/4595263 to your computer and use it in GitHub Desktop.
not sure how to handle the redirect response in the resource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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') | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="span6" id="activities"> | |
<h3 class="span2">Activity</h3> | |
{{activities[0].actor.avatar()}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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