0
我想有getCurrentSongData函數返回從刮刀傳入的songdata對象,但我不斷收到這樣的輸出:無法從另一個js文件中的NodeJS出口對象
******************TESTING****************
c:\Users\(PATH TO PROJECT FOLDER)\node_modules\mysql\lib\protocol\Parser.js:82
throw err;
^
TypeError: Cannot read property 'artist' of undefined
at getCurrentSongData
...
這裏的我的routes.js文件的一部分,需要我的刮板。
function getCurrentSongData(un) {
var scraper = require('./scrape');
console.log("******************TESTING****************");
console.log("testfunct: " + scraper(un).artist);
return scraper(un);
}
我不知道如何將其應用於我的代碼。函數dataLoaded是否在我的routes.js文件中或在scraper中? –
@NickR。 http://pastebin.com/cKNL9dij –
所以如果我試圖從scraper的結果加載到routes.js文件我會把這個在routes.js?它似乎沒有工作。 我也有一條路線: res.render('nowplaying.ejs',{songdata:getCurrentSongData(lastfm)}); –