Node.js how to use callback to send data to web interface
<p>I have two functions that query the twitter api. The query is done through a web interface and I call each function when a checkbox is on. My problem now is after all the querying has been done, I want to be able to store the data and send it back to the web interface. How do I do this ?</p>

<pre><code>    if (string.checktweet1 == 'on') {
      tweets(string.teamname)
    }
    if (string.checkmentions1 == 'on'){
      mentions(string.teamname)
    }
    if (string.checktweet2 == 'on'){
      tweets(string.playername)
    }

    if (string.checkmentions2 == 'on'){
      mentions(string.playername)
    }
</code></pre>

<hr>

<pre><code>      function mentions(x){
         client.get('search/tweets', {q:x, count:1},
         function (err,data,){
            for(var index in data.statuses){
               var tweet = data.statuses[index];
               console.log(tweet.text);
            }
       })
     }
</code></pre>

<p>My code is only sending the data for the function "tweets"</p>

<pre><code>      json = {};
     function tweets(y){
       client.get('statuses/user_timeline', {screen_name:y, count:1},
       function(err,data) {
         for(var index in data){
           var tweet = data[index];
           console.log(tweet.text);
         }
          json[index] = tweet
          res.end(JSON.stringify(json));
      })
    }
</code></pre>