不知道它是如何可能的,但有些我试图使用我在同一文件中导出的函数。
exports.OnefunCall = function (session, builder, properties) {
var request = require("request");
request(url, function (error, response, body)
{
if (!error && response.statusCode == 200) {
displayOnefunCallAnswer(body, session, builder);
} else {
session.send('Something went wrong. You can use the back or top command.');
//session.beginDialog('/menu');
}
});
}
function displayOnefunCallAnswer(entityData, session, builder) {
// Code for display data
}
我有另一个功能,我需要发出OnefunCall请求。我可以使用如下。
exports.AnotherfunCall = function (session, builder, properties) {
// Some logic to perform AnotherfunCall and if the response is correct then call the OnefunCall
module.exports.OnefunCall(session, builder, properties);
}
还是有其他方法可以执行此操作。
答案 0 :(得分:1)
是的,如果您只想导出,可以按照以下示例
function OnefunCall (session, builder, properties) {
//do some code
}
function AnotherfunCall (session, builder, properties) {
//do some code
OnefunCall(a,b,c){
}
}
exports.OnefunCall = OnefunCall;
exports.AnotherfunCall = AnotherfunCall;