How to scope datat ? Here datat is empty. And i would like to put data in a var so i can use it outside the function.
var datat;
twit.search('#louieck', {include_entities:true,page:paget,maxid:maxidt}, function(data) {
// and output to the console:
datat = data;
});
sys.puts(sys.inspect(datat));
Regards
Bussiere
'datat' is scoped outside your function. twit.search is async and therefore may not return 'data' before you check 'datat' with sys.inspect.
This should let you see datat:
var datat;
twit.search('#louieck', {include_entities:true,page:paget,maxid:maxidt}, function(data) {
// and output to the console:
datat = data;
sys.puts(sys.inspect(datat));
});
But ideally you'd use a callback like this...
var datat;
var callback = function(d){
sys.puts(sys.inspect(d));
datat = d;
// do something more with datat
};
twit.search('#louieck', {include_entities:true,page:paget,maxid:maxidt}, function(data) {
callback(data);
});
EDIT - simplified as per comment...
var datat;
var callback = function(d){
sys.puts(sys.inspect(d));
datat = d;
// do something more with datat
};
twit.search('#louieck', {include_entities:true,page:paget,maxid:maxidt},callback(data));