title: Can't access variables outside of function/callback
body: <p>I'm trying to call a weather API to get the current weather for a bot. I'm using <a href="https://github.com/aacerox/node-rest-client" rel="nofollow">node-rest-client</a> to pull a description of the weather, which will be held in <code>context.forecast</code>. The only problem is, I can't seem to modify/create the variable inside the function or access it outside of the function. Here's my code:</p>
  
  <pre><code>'fetch-forecast': (sessionId, context, cb) =&gt; {
      var url = "http://api.openweathermap.org/data/2.5/weather?q="+context.location+"&amp;APPID=APIKEY";
      var forecast;
      Client.get(url, (data, response) =&gt; {
        context.forecast = data.weather[0].description;
      });
      cb(context);
    }
  </code></pre>
  
  <p><code>context.forecast</code> returns undefined. Something like this doesn't seem to work either: </p>
  
  <pre><code>  'fetch-forecast': (sessionId, context, cb) =&gt; {
      var url = "http://api.openweathermap.org/data/2.5/weather?q="+context.location+"&amp;APPID=APIKEY";
      var forecast;
      Client.get(url, (data, response) =&gt; {
        forecast = data.weather[0].description;
      });
      context.forecast = forecast;
      cb(context);
    }
  </code></pre>
  
  <p><code>context.forecast</code> also returns undefined here. Any ideas on what I'm doing wrong?</p>
  
  <p>[Edit] Tried something like this, but I'm still unable to edit the <code>context.forecast</code> variable: </p>
  
  <pre><code>  'fetch-forecast': (sessionId, context, cb) =&gt; {
      var location = context.location;
      var url = "http://api.openweathermap.org/data/2.5/weather?q="+location+"&amp;APPID=APIKEY";
      var forecast;
      function getWeather(url) {
        return new Promise(function(resolve, reject) {
          Client.get(url, (data, response) =&gt; {
            resolve(data.weather[0].description);
          });
        });
      }
  
      getWeather(url).then(function(result) {
        context.forecast = result;
        console.log(context.forecast)
      }).catch(function() {
        context.forecast = "not found";
      });
      console.log(context.forecast);
      cb(context);
    }
  </code></pre>
  
  <p>The second <code>console.log</code> returns <code>undefined</code> first, and the first <code>console.log</code> returns the actual value second. I'm still at a loss for why this is happening.</p>