0

不知道这是怎么可能的,但有些我正在尝试使用我在同一个文件中导出的功能。

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);
}

还是有其他方法可以执行此操作。

4

1 回答 1

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;
于 2017-05-12T07:32:57.760 回答