Scenarios 1:
I have two file in my atom project weather.js and exmaple.js and weather is using export module to export everything to example.js and in turn example.js is using require module
my weather.js
var request = require('request');
module.exports= function(justAnothercallback)
{
justAnothercallback('This is from weather');
}
myExample.js
var fromWeather = require('./weather.js');
fromWeather(function(weather){
console.log(weather);
});
If I do Node myExample.js the output is :
This is from weather
Scenarios 2:
Now I just pass one more callback in my weather.js
module.exports= function(justAnothercallback, SecondCallback) {
justAnothercallback('This is from weather');
SecondCallback('This is second callback)');
}
And my example.js is modified to accommodate the second callback function !!
var fromWeather = require('./weather.js');
fromWeather(function(weather, anotherfunc){
console.log(weather);
console.log(anotherfunc);
});
From the terminal we get :
/>node example-callback.js This is from weather undefined /Users/NodeCourse/async/weather.js:7 SecondCallback('This is second callback)'); ^
TypeError: SecondCallback is not a function at module.exports (/Users/oogway/NodeCourse/async/weath
My question is are they not the same , I just added one more callback and it barfed !! why !!?? but it works fine if I pass just one callback .. Please help one this .