title: How to manipulate Twilio data object? nodeJS
body: <p>How can I put the info in variable 'data' into the new variable 'newData'?</p>
  
  <pre><code>var accountSid = '12345';
  var authToken = "12345";
  var client = require('twilio')(accountSid, authToken); 
  
  app.get("/results", function(req,res){
     var query = req.query.search
     var newData;
  
     // Retrieve list of messages
     client.messages.list(query, function(err, data) {
         if(err){console.log(err)} 
         else {
           // Pass info into 'newData'
           newData = data;
         }
     });
  
  console.log(newData);
  
  res.render("results", {data: newData});
  });
  </code></pre>
  
  <p>The above code results in 'newData' being undefined.</p>
  
  <p>If do this:</p>
  
  <pre><code>        else {
           // Render raw 'data'
           res.render("results", {data: data});
         }
  </code></pre>
  
  <p>The code works fine. However, I want to manipulate the data <em>outside</em> of the function.</p>