I am trying to create functions file for my project with node js (v6.14.3).
From test file I am using 'require' to call my helper.js file (the function file), and access the gethttp function I created. First I tried to use async/await and then realize it used in older versions.
I saw I need to use promise/callback and didn't understand how.
helper.js :
const http = require('http');
module.exports.gethttp = function(url){
    http.get(url, (resp) =>{
        let data = '';
         resp.on('data', (chunk) =>{
             data += chunk;
         });
         resp.on('end', (data) =>{
             return data;
         });
    }).on('error',  (err) =>{
        console.log(err);
    });
}
test.js :
var helper = require('./helper');
var req = helper.gethttp("the url");
console.log(req);
and getting the output of undefined...
 
     
     
    