common-node
common-node copied to clipboard
Question: How to require the file for making a request?
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:
- Run app() within the same file.
- 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.