Skip to content
This repository was archived by the owner on Feb 25, 2020. It is now read-only.
This repository was archived by the owner on Feb 25, 2020. It is now read-only.

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

@JemiloII

Description

@JemiloII

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions