Javascript functions var global

I am trying to use this script: https://github.com/peol/node-spotify

And I can't figure out how to make

spotify.search({ type: 'track', query: 'dancing in the moonlight' }, function(err, data){
   return data; 
});

data globaly available?

i tried like butin var data = in front of that but it didn't help

If you need that data to be available "globally" in the current file scope, just define another var outside that call:

var myData;
spotify.search({ type: 'track', query: 'dancing in the moonlight' }, function(err, data){
  myData = data;
});

If you need it to be available globally across your Node process, then do the following:

spotify.search({ type: 'track', query: 'dancing in the moonlight' }, function(err, data){
  global.myData = data;
});