My variable "whole" is undefined.
getStudents.js
var http = require('http');
module.exports = {
'sendResults': function(){
http.get(' http://gs-class.com/nodejs/students.php', function(res){
var whole = '';
res.on('data',function(chunk){
whole+=chunk;
});
res.on('end', function(){
return whole;
});
});
}
}
studWrite.js
var getStudents = require('./getStudents');
var fs = require('fs');
var results = getStudents.sendResults();
console.log(results);
and when I am running the program studWrite.js my var 'whole' is undefined. pls help.