节点 - 在同一文件中导出
Node - Export in the same file
不知道这怎么可能,但有些我正在尝试使用我在同一个文件中导出的功能。
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);
}
或者有没有其他方法可以执行此操作。
是的,如果你只是想导出你可以按照下面的例子
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;
不知道这怎么可能,但有些我正在尝试使用我在同一个文件中导出的功能。
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);
}
或者有没有其他方法可以执行此操作。
是的,如果你只是想导出你可以按照下面的例子
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;