Thursday, 25 August 2016

Method Call in Node.js

#  Here we will learn how to call Method in Node.js


MethodClient.js 

/**
 * Created by Anand Dwivedi on 8/26/2016.
 */

 var response = require('./method.js');
console.log(response);
/*
Other way to call Method
 */
response.data.addData(2,3);



Method.js


/**
 * Created by Raghavendra on 8/26/2016.
 */

var methods={};
var  output=1000;

methods.eatCookies=function () {
    console.log('eat Method Invoke');
};
methods.SetServer=function () {
    console.log('SetServer Method Invoke');
};

methods.getName=function () {
    console.log('getName Method Invoke');
};

methods.addData=function(a,b){
    output=Number(a)+Number(b);
    console.log('Addition is'+output);
    return output;
}

exports.data=methods;
exports.output=output;





No comments:

Post a Comment