【发布时间】:2017-12-08 05:10:45
【问题描述】:
我有一个 .js 文件如下:
module.exports = {
metadata: () => ({
"name": "HrScheduleApi",
"properties": {
"scheduleDate": {"type": "string", "required": false}
}
}),
invoke: (conversation, done) => {
var actionType = conversation.properties().actionType;
logger.info("start of HrScheduleApi with action type:" + actionType);
if(isBeyondThreeDays(scheduleDate) == false){
dayFromNow = '2 days from now';
var tomorrow = new Date(new Date().getTime() + 48 * 60 * 60 * 1000);
schDate = tomorrow.toDateString();
}else{
console.log('asked schedule is beyond 48 hours');
}
},
isBeyondThreeDays: (scheduleDate) => {
// ...
}
};
所以当我在调用函数中需要一个新函数 (isBeyondThreeDays) 时,我只是定义如下。但似乎 nodejs 不喜欢它。我得到错误 在运行时为:
Error in component, details={}
ReferenceError: isBeyondThreeDays is not defined
【问题讨论】:
-
你能展示你如何导入这个模块并调用这个函数吗?
-
您显示的错误在于您如何调用
obj.isBeyondThreeDays(),因此我们需要查看发生实际错误的调用代码。以后,请始终显示确切的错误消息和发生错误的代码行以及相关上下文。 -
修改了代码以显示我是如何调用的
标签: node.js