node.js - Reset Password in nodejs -
i writing script in user can reset password.
user email
when user click on link. form open , user can enter new password. route code
app.get('/resetpassword/:token', function (req, res, next) { var filelocation = path.resolve(__dirname + '/../public/resetpassword.html'); console.log(filelocation); res.sendfile(filelocation); }); app.post('/setnewpassword', function(req,res,next){ console.dir(req.body); });
and html there
<form action="/setnewpassword" method="post"> <div> <label>password:</label> <input type="password" name="password" /> </div> <input type="submit" value="submit" /> </form>
now problem not getting params under app.post('/setnewpassword'
any idea? how params under setnewpassword.
i want use post method only
var bodyparser = require('body-parser') // parse application/x-www-form-urlencoded app.use(bodyparser.urlencoded({ extended: false })) // parse application/json app.use(bodyparser.json())
make sure place code before post handlers.
Comments
Post a Comment