【发布时间】:2019-07-20 04:34:22
【问题描述】:
我正在编写一个 Node.js 应用程序,我正在尝试使用我的 index.js 文件中的函数。每当我添加
var IndexBot = require('/root/afstudeerwerk/chatbotPIROS/index');
对于我的 calls.js 文件,我收到以下错误:
错误1:
routes.js (/root/afstudeerwerk/chatbotApi/api/routes):
'use strict';
module.exports = function(app) {
var chatbot = require('/root/afstudeerwerk/chatbotPIROS/calls');
app.post('/slack/receive',chatbot.create_a_message);
app.post('/DBcheck/:id',chatbot.checkUserAuth);
};
calls.js (/root/afstudeerwerk/chatbotPIROS/calls)
'use strict';
exports.create_a_message = function(req, res) {
var IndexBot = require('/root/afstudeerwerk/chatbotPIROS/index');
var message = req.body;
var button = JSON.parse(message.payload).actions[0].value
if(button == 'MeanMakeVM'){
res.json({message:'Please enter your VM specs.'});
IndexBot.stuur_bot_bericht('dit is een testbericht.');
}
【问题讨论】:
标签: node.js function object npm callback