Thursday, 11 May 2017

Node - Exporte in the same file

Don't know how it is possible but some how I'm trying to use the function that I am exporting 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
}

I have another function where I need to make the OnefunCall request. Can I use as below.

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

or is there any another way to perform this operation.



via Mukesh25

No comments:

Post a Comment