javascript - How to split the function to two differnt file nodejs -


Hello I'm new in node js so please do not mind when it's incorrect.

I have a file like

  exports.Client = function () {this.example = function (name, callback) {console.log (name); }; This.example1 = function (name1, callback) {console.log (name1); }; };  

I need to use

  var client = ('./ client.js') in this way. Customer; Var client = new client (); Client.example1 = .....  

How can I split the example1 function into another JS file and still use the client object to access it.

I recommend reading this page:

Your Javascript module function Should be exported to module.exports .

The contents of the example 1.js file:

  module. Exports.Emploom1 = Function (name1, callback) {console.log (name1); };  

You can access the function to require a function in your client.js file:

  var example1 = Required ('./example1.js').example1; Module.exports.Client = function () {this.example = function (name, callback) {console.log (name); }; This.example1 = example1; };  

Be careful, the nodes module is a solo song.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -