运用querystring.stringify(object)转换对象时,展现的结果,没有我想要的key
发布于 8 年前 作者 wdlhao 4356 次浏览 来自 问答

32.png 展现的结果看不懂,求大神帮忙!

4 回复

求大神帮忙!

不发源码怎么帮你

@MiguelValentine 您好,当传入content的值为汉字时,会报错,报错信息见图,关键是object-转换为string的结果也看不懂 module.exports.commentEditPage = function (req, res) { console.log(“commentEditPage enter”); var topicid = req.params.topicid; var commentid = req.body.commentid; console.log(“topicid333:”, topicid + “, commentid333:”, commentid); if (!req.params.topicid || !req.body.commentid) { sendJSONresponse(res, 404, { “message”: “Not found, topicid and commentid are both required” }); return; } TopicModel .findById(req.params.topicid) .select(‘comments’) .exec( function(err, topic) { if (!topic) { sendJSONresponse(res, 404, { “message”: “topicid not found” }); return; } else if (err) { sendJSONresponse(res, 400, err); return; } if (topic.comments && topic.comments.length > 0) { console.log(“comment_length:”, topic.comments.length); comment = topic.comments.id(req.body.commentid); console.log(“comment”, comment); console.log(“comment”,querystring.stringify( comment)); if (!comment) { sendJSONresponse(res, 404, { “message”: “commentid not found” }); } else { result = { //content: iconv.decode(new Buffer(“我们的祖国”,‘utf-8’),‘utf-8’), content:“好好学习,天天向上”, commentId: comment._id }; console.log(“topic.comments enter222”); sendJSONresponse(res, 200, result); } }else{ sendJSONresponse(res, 404, { “message”: “No comment to delete” }); } } ); }; 39.jpg

回到顶部