I make web site with express and I need gravatar image, so https://npmjs.org/package/gravatar
npm install gravatar
and my app.js
in my app.js
var gravatar = require('gravatar');
http.createServer(app).listen(app.get('port'), function(){
var secureUrl = gravatar.url('[email protected]' , {s: '100', r: 'x', d: 'retro'}, true);
console.log(secureUrl);
console.log('Express server listening on port ' + app.get('port'));
});
working very well, and Browser show me nice picture.
but I use express, and use post method like this,
app.post('/signup', routes.signupResult);
and full of my example source index.js
exports.signupResult = function(req, res){
res.render('user/signup-result', {
title: 'Node-Chat Sign up'
, name: req.body.name
, email: req.body.email
, password: req.body.password
, password: req.body.passwordConfirmation
});
};
I want my signup-result.jade will use gravatar profile image...
what can I do my app.js
to routes/index.js
edit for gravatar?
You forgot to
require
thegravatar
lib in your index.js file.Add this at the top :
var gravatar = require('gravatar');
And also, in your render call add this
avatar: gravatar.url(req.body.email , {s: '100', r: 'x', d: 'retro'}, true)
.