I want to use markdown to save the data securely instead of json.stringfy() method.Like this exapmle:usercomment is <script>alert('ss')</script>
app.get('/comment',function(req.res){
var usercomment=req.body.comment;//from comment textarea(user's comment)
const x=markdown.toHTML(usercomment);
var comments=new comment({user:req.session.nick,comment:x});
comments.save();
console.log(x)
}
Or use json.stringify() like this I save the usercomment with json.stringify().Later i will send the comment(from database) to html with markdown.toHTML(comment):
app.get('/comment',function(req.res){
var usercomment=req.body.comment;
const x=JSON.stringify(usercomment);
var comments=new comment({user:req.session.nick,comment:x});
comments.save();
console.log(x)
}