500 TypeError:C:\ Users \ lvcpp \ Docs \ evernote-sdk-js \ sample \ express \ views \ index.jade:31 29 |li = session.notebooks [i] .name 30 |ul> 31 |-对于(var i = 0; i< session.notesMeta.length; ++ i)32 |li = session.notesMeta.notes [i] .title 33 |hr 34 |h2当前状态无法读取未定义的属性长度" 29 |li = session.notebooks [i] .name 30 |ul > 31 |-对于(var i = 0; i< session.notesMeta.length ; ++ i)32 |li = session.notesMeta.notes [i] .title 33 |hr 34 |h2当前状态 Express js网络应用程序: //index.js: ... exports.index = function(req,res){if(req.session.oauthAccessToken){var令牌= req.session.oauthAccessToken;var client = new Evernote.Client({令牌:令牌,沙箱:config.SANDBOX});var noteStore = client.getNoteStore();noteStore.listNotebooks(function(err,notebooks){req.session.notebooks =笔记本;res.render('index');});var notebook = noteStore.getDefaultNotebook(function(err,notebook){filter =新的Evernote.NoteFilter();filter.notebookGuid = notebook.guid;resultSpec =新的Evernote.NotesMetadataResultSpec();resultSpec.includeTitle = true;noteStore.findNotesMetadata(filter,0,100,resultSpec,function(err,notesMeta){req.session.notes =笔记;res.render('index');});});} 别的 {res.render('index');}}; //index.jade ... ul-对于(var i = 0; i< session.notebooks.length; ++ i)li = session.notebooks [i] .nameul-对于(var i = 0; i< session.notesMeta.length; ++ i)li = session.notesMeta.notes [i] .title p.s.谢谢@conch,但不幸的是,之后代码修复: 500 TypeError:C:\ Users \ lvcpp \ Docs \ evernote-sdk-js \ sample \ express \ views \ index.jade:3129 |li = session.notebooks [i] .name 30 |ul> 31 |-对于(var i = 0; i<session.notesMeta.notes.length;++ i)32 |li =session.notesMeta.notes [i] .title 33 |hr 34 |h2当前状态无法读取未定义的属性注释" 29 |li = session.notebooks [i] .name 30 |ul > 31 |-对于(var i =0;我<session.notesMeta.notes.length;++ i) 32 |li =session.notesMeta.notes [i] .title 33 |hr 34 |h2当前状态 我们需要在index.js中定义'notes'属性.但是如何处理,或者我们真的需要它来处理吗?在我的控制台nodejs应用程序中,所有事情都可以运行,而无需对注释进行特殊定义: function showlistNotes(){filter =新的Evernote.NoteFilter();resultSpec =新的Evernote.NotesMetadataResultSpec();resultSpec.includeTitle = true;noteStore.findNotesMetadata(filter,0,100,resultSpec,function(err,notesMeta){如果(错误){console.error('err',err);}别的 {console.log("\ n在所有笔记本中找到" + notesMeta.notes.length +笔记:");为(在notesMeta.notes中的var i){console.log(i +:" + notesMeta.notes [i] .title);}console.log('\ n获取所选笔记的内容(请从所有笔记本中查看笔记的完整列表):\ n请在0到'+ notesMeta.notes.length之间插入数字);process.openStdin().addListener("data",function(d){var a = d.toString().trim();noteStore.getNote(notesMeta.notes [a] .guid,true,true,true,true,function(err,note){console.log(err || ENML.PlainTextOfENML(note.content,note.resources));});});}});} 解决方案失败了,因为您的js文件在noteStore.findNotesMetadata的回调中设置了一个名为 notes 的会话变量,但是您的jade文件是期望的一个名为 notesMeta 的会话变量.您的Jade文件也有一个索引错误(您不应该通过 session.notesMeta 进行迭代,而应该通过 session.notesMeta.notes 进行迭代).正确的代码: index.js noteStore.findNotesMetadata(filter,0,100,resultSpec,function(err,notesMeta){req.session.notesMeta = notesMeta;res.render('index');}); index.jade ul-对于(var i = 0; i< session.notesMeta.notes.length; ++ i)li = session.notesMeta.notes [i] .title Do you know how to Show the title & content for all the Evernote notes in Express js ? https://github.com/evernote/evernote-sdk-js/blob/master/sample/express/routes/index.js https://github.com/evernote/evernote-sdk-js/blob/master/sample/express/views/index.jade500 TypeError: C:\Users\lvcpp\Docs\evernote-sdk-js\sample\express\views\index.jade:31 29| li= session.notebooks[i].name 30| ul > 31| - for (var i = 0; i < session.notesMeta.length; ++i) 32| li= session.notesMeta.notes[i].title 33| hr 34| h2 Current status Cannot read property 'length' of undefined29| li= session.notebooks[i].name30| ul> 31| - for (var i = 0; i < session.notesMeta.length; ++i)32| li= session.notesMeta.notes[i].title33| hr34| h2 Current statusExpress js web app://index.js:...exports.index = function(req, res) { if(req.session.oauthAccessToken) { var token = req.session.oauthAccessToken; var client = new Evernote.Client({ token: token, sandbox: config.SANDBOX }); var noteStore = client.getNoteStore(); noteStore.listNotebooks(function(err, notebooks){ req.session.notebooks = notebooks; res.render('index'); }); var notebook=noteStore.getDefaultNotebook(function (err, notebook){ filter = new Evernote.NoteFilter(); filter.notebookGuid = notebook.guid; resultSpec = new Evernote.NotesMetadataResultSpec(); resultSpec.includeTitle=true; noteStore.findNotesMetadata(filter, 0, 100, resultSpec, function(err, notesMeta) { req.session.notes = notes; res.render('index'); }); }); } else { res.render('index'); }};// index.jade...ul - for (var i = 0; i < session.notebooks.length; ++i) li= session.notebooks[i].nameul - for (var i = 0; i < session.notesMeta.length; ++i) li= session.notesMeta.notes[i].title p.s. Thanks, @conch, but unfortunately I get another error, after the fixes of code: 500 TypeError: C:\Users\lvcpp\Docs\evernote-sdk-js\sample\express\views\index.jade:31 29| li= session.notebooks[i].name 30| ul > 31| - for (var i = 0; i < session.notesMeta.notes.length; ++i) 32| li= session.notesMeta.notes[i].title 33| hr 34| h2 Current status Cannot read property 'notes' of undefined 29| li= session.notebooks[i].name 30| ul > 31| - for (var i = 0; i < session.notesMeta.notes.length; ++i) 32| li= session.notesMeta.notes[i].title 33| hr 34| h2 Current status We need to define the 'notes' property in index.js.But how to, or do we really need it to deal with ?In my console nodejs app all the things works without the special definition of notes:function showlistNotes() { filter = new Evernote.NoteFilter(); resultSpec = new Evernote.NotesMetadataResultSpec(); resultSpec.includeTitle=true; noteStore.findNotesMetadata(filter, 0, 100, resultSpec, function(err, notesMeta) { if (err) { console.error('err',err); } else { console.log("\nFound "+notesMeta.notes.length+" notes in all the notebooks:"); for (var i in notesMeta.notes) { console.log(i+": "+notesMeta.notes[i].title); } console.log('\nGet the contents of the selected note (see full list of notes, from all your notebooks):\nPlease insert the number from 0 to ' + notesMeta.notes.length ); process.openStdin().addListener("data", function(d) { var a=d.toString().trim(); noteStore.getNote(notesMeta.notes[a].guid, true, true, true, true, function(err, note) { console.log(err || ENML.PlainTextOfENML(note.content, note.resources) ); }); }); } });} 解决方案 It's failing because your js file sets a session variable called notes in the callback of noteStore.findNotesMetadata, but your jade file is expecting a session variable called notesMeta. Your jade file also has an indexing error (you should not be iterating through session.notesMeta, you should be iterating through session.notesMeta.notes).The correct code:index.jsnoteStore.findNotesMetadata(filter, 0, 100, resultSpec, function(err, notesMeta) { req.session.notesMeta = notesMeta; res.render('index');});index.jadeul - for (var i = 0; i < session.notesMeta.notes.length; ++i) li= session.notesMeta.notes[i].title 这篇关于如何在Express js中显示每个Evernote笔记的标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-23 04:18