E:\mynode\blog\node_modules\mongodb\lib\utils.js:97 process.nextTick(function() { throw err; }); ^
TypeError: Cannot read property ‘slice’ of undefined at convert_tree_to_html (E:\mynode\blog\node_modules\markdown\lib\markdown.j s:1556:20) at Object.toHTMLTree (E:\mynode\blog\node_modules\markdown\lib\markdown.js:1 12:14) at Object.toHTML (E:\mynode\blog\node_modules\markdown\lib\markdown.js:82:22 ) at E:\mynode\blog\models\post.js:90:33 at Array.forEach (native) at E:\mynode\blog\models\post.js:89:16 at handleCallback (E:\mynode\blog\node_modules\mongodb\lib\utils.js:95:12) at E:\mynode\blog\node_modules\mongodb\lib\cursor.js:772:16 at handleCallback (E:\mynode\blog\node_modules\mongodb\node_modules\mongodb- core\lib\cursor.js:244:5) at setCursorDeadAndNotified (E:\mynode\blog\node_modules\mongodb\node_module s\mongodb-core\lib\cursor.js:548:3)
@yanglinnie 应该是使用markdown这个模块时出现的问题,因为是新手第一次用这个模块,
docs.forEach(function (doc) {
doc.post = markdown.toHTML(doc.post);
});
想把数据库里发表的文章装换为html展示出来
docs.forEach(function (doc) {
//doc.post = markdown.toHTML(doc.post);
});
当我注释这句的时候,就不会在后台报错误了。