我创建了一个Azure时间触发器功能,我想和他一起读取一个Json文件.我确实安装了read-json和jsonfile包并尝试了两者,但它没有用.这是一个示例函数
module.exports = function (context, myTimer) {
var timeStamp = new Date().toISOString();
var readJSON = require("read-json");
readJSON('./publishDate.json', function(error, manifest){
context.log(manifest.published);
});
context.log('Node.js timer trigger function ran!', timeStamp);
context.done();
};
Run Code Online (Sandbox Code Playgroud)
这是错误的:
TypeError: Cannot read property 'published' of undefined
at D:\home\site\wwwroot\TimerTriggerJS1\index.js:8:29
at ReadFileContext.callback (D:\home\node_modules\read-json\index.js:14:22)
at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:365:13).
Run Code Online (Sandbox Code Playgroud)
Json文件与index.js位于同一文件夹中.我假设由于路径'./publishDate.json'而发生此错误,如果是这样,我应该如何键入有效路径?