I have a question, how to make page accessable after some html element click, for example, I want to go there: http://localhost:8001/user/someId/edit. I have created a route for editing user information
router.put('/user/:id/edit', function(req,res,next){
....
}
Now I want to redirect to that page, here is a route that I'm currently trying to redirect - user/:id/edit
router.get('/edit', function(req,res,next){
ssn = req.session;
var urlId;
var ObjectId = require('mongodb').ObjectID;
mongo.connect(url, function(err, db){
assert.equal(null,err);
var cursor = db.collection('student-data').insert({'username':ssn.username}, function(error, result){
urlId=JSON.stringify(result["ops"][0]["_id"]);
//console.log();
db.close;
});
});
res.redirect('/user/'+ObjectId(urlId)+'/edit/');
});
There I tried to access this page with span
a(href='edit')
span.change Change username
I hope you guys understood what i wrote and what I want. Thank you in advance!
via Simon Draymon
No comments:
Post a Comment