common-node icon indicating copy to clipboard operation
common-node copied to clipboard

Question: How to require the file for making a request?

Open JemiloII opened this issue 9 years ago • 0 comments

I'm looking at the example you provided

var HttpClient = require('common-node').httpclient.HttpClient;

exports.app = function(request) {
  return {
    status: 200,
    headers: {},
    body: new HttpClient({
      url: 'http://google.com'
    }).finish().body
  };
};

if (require.main == module) {
  require('common-node').run(exports);
}

Here is a page I try to require it.

var get = require('./index');

var page = get.app();

console.log(page);

I've even tried to do

module.exports.app =

I tried including it,but i'm not sure how to:

  1. Run app() within the same file.
  2. Run app within another file.

I'm trying to use node to start my script so the script can easily be adopted by the team. So far I love it. This is what I've been searching for.

JemiloII avatar Mar 19 '15 11:03 JemiloII