title: passing parsed json data to template
body: <p>Parsing JSON data from openweathermaps. Console.log works, but data won't pass to ejs template. I keep getting "data undefined" error. </p>
  
  <p>Viewed numerous video tutorials, Teaching assistants, but nothing catching. Seems like a simple thing, just overlooking some small detail. Or maybe it needs an entire rewrite. </p>
  
  <pre><code>app.use(function (req, res, next) {
      let apiKey = "***************************";
      let city = "Providence,US";
      let url = `http://api.openweathermap.org/data/2.5/weather? 
      q=${city}&amp;units=imperial&amp;appid=${apiKey}`;
  
    request(url, function (error, response, body) {
        if (!error &amp;&amp; response.statusCode == 200) {
        let weather = JSON.parse(body);
        let data = `temp ${weather.main.temp}  wind ${weather.wind.speed} 
        from ${weather.wind.deg}`;
        res.locals.weather = data;
        console.log(data);
        res.locals.error = null;
        next();
        } else {
        res.locals.data = null;
        res.locals.error = "There was an error current weather data.";
        next();
        }
      });
    });
  
  app.get("/", (req, res) =&gt; {
      res.render("index",  {data: data});
  });
  
  
  app.listen(process.env.PORT || 3000, () =&gt; {
      console.log("SERVER IS RUNNING!");
  });
  </code></pre>
  
  <p>Console.log yields parsed temperature, wind and direction. Running in the browser yields error "ReferenceError: data is not defined
      at app.get (/workspace/UdemyWebDev/c9Backup/weatherCall/app.js:42:30)", pointing to the {data: data} object in the res.render callback.
  Using res.locals is still a mystery after hours puzzling over it. Any help would be appreciated.</p>