title: How can I use multiple res.renders in Express.js
body: <p>I'm making a web application using Express.js in Node.js that tells the weather of the city the users input + a random Kanye west quote. For that purpose, I am using the data of <strong>two APIs</strong> so that I can fetch the data and display it in the <strong>final.ejs</strong> file, but how can I use two <strong>res.renders</strong> in my <strong>app.js</strong>.</p>
  <p><strong>app.js</strong></p>
  <pre><code>    //jshint esversion: 6
  
  const express = require(&quot;express&quot;);
  const bodyParser = require(&quot;body-parser&quot;);
  const https = require(&quot;https&quot;);
  
  const app = express();
  
  app.set('view engine', 'ejs');
  
  app.use(express.static(&quot;public&quot;));
  
  app.use(bodyParser.urlencoded({ extended: true })); 
  
  
  app.listen(3000, function(req,res){
      console.log(&quot;Server started running on port 3000&quot;);
  });
  
  app.get(&quot;/&quot;, function(req, res){
      res.sendFile(__dirname + &quot;/index.html&quot;);
  });
  
  app.post(&quot;/&quot;, function(req, res)
  {
      let cityName = req.body.cityName;
      let weatherUrl = &quot;https://api.openweathermap.org/data/2.5/weather?q=&quot; + cityName + &quot;&amp;units=metric&amp;appid=3c6398acf0105933ccb43e63d0fd8b18&quot;;
      https.get(weatherUrl, function(response)
      {
          console.log(response.statusCode);
          response.on(&quot;data&quot;, function(data)
          {
              let weatherData = JSON.parse(data);
              let temp = weatherData.main.temp;
              let desc = weatherData.weather[0].description;
  
              res.render(&quot;final&quot;, {cityNameFinal: cityName, cityTemperature: temp, cityDescription: desc});
          });
      });
  
      let kanyeUrl = &quot;https://api.kanye.rest/&quot;;
      https.get(kanyeUrl, function(response)
      {
          console.log(response.statusCode);
          response.on(&quot;data&quot;, function(data)
          {
              let quoteDate = JSON.parse(data);
              let quote = quoteDate.quote;
  
              res.render(&quot;final&quot;, {kanyeQuote: quote});
          });
      });
  });
  
  //For the &quot;Search for another city&quot; button
  app.post(&quot;/home&quot;, function(req, res){
      res.redirect(&quot;/&quot;);
  });
  </code></pre>
  <p><strong>index.html</strong></p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot; /&gt;
      &lt;meta name=&quot;author&quot; content=&quot;Jyotirmay Patel&quot; /&gt;
      &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot; /&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt;
      &lt;title&gt;Weather App&lt;/title&gt;
  
      &lt;!-- Google Fonts --&gt;
      &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.gstatic.com&quot;&gt;
      &lt;link href=&quot;https://fonts.googleapis.com/css2?family=Fredericka+the+Great&amp;family=Press+Start+2P&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt;
  
      &lt;!-- Custom CSS --&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;styles.css&quot;&gt;
  
      &lt;!-- Bootstrap Styles CDN --&gt;
      &lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot; integrity=&quot;sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x&quot; crossorigin=&quot;anonymous&quot;&gt;
  &lt;/head&gt;
  
  &lt;body id=&quot;main&quot;&gt;
      &lt;h1 class=&quot;heading-1&quot;&gt;Weather App&lt;/h1&gt;
      &lt;h1 class=&quot;heading-2&quot;&gt;+ Random Kanye West Quotes&lt;/h1&gt;
      &lt;hr&gt;
  
      &lt;div class=&quot;container&quot;&gt;
          &lt;div class=&quot;row&quot;&gt;
              &lt;div class=&quot;col-md-6 main-container&quot;&gt;
                  &lt;form action=&quot;/&quot; method=&quot;POST&quot;&gt;
                      &lt;label class=&quot;city-label&quot; for=&quot;&quot;&gt;Please enter the City Name: &lt;/label&gt;
                      &lt;br&gt;
                      &lt;input class=&quot;cityName-input&quot; type=&quot;text&quot; name=&quot;cityName&quot; id=&quot;&quot; placeholder=&quot;Enter a City&quot;&gt;
                      &lt;br&gt;
                      &lt;button class=&quot;btn btn-secondary btn-lg&quot; type=&quot;submit&quot;&gt;Submit&lt;/button&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;!-- Bootstrap Scripts CDN --&gt;
      &lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot; integrity=&quot;sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x&quot; crossorigin=&quot;anonymous&quot;&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  <p><strong>final.ejs</strong></p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot; /&gt;
      &lt;meta name=&quot;author&quot; content=&quot;Jyotirmay Patel&quot; /&gt;
      &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot; /&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt;
      &lt;title&gt;Weather App&lt;/title&gt;
  
      &lt;!-- Google Fonts --&gt;
      &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.gstatic.com&quot;&gt;
      &lt;link href=&quot;https://fonts.googleapis.com/css2?family=Fredericka+the+Great&amp;family=Press+Start+2P&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt;
  
      &lt;!-- Custom CSS --&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;list-styles.css&quot;&gt;
  
      &lt;!-- Bootstrap Styles CDN --&gt;
      &lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot; integrity=&quot;sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x&quot; crossorigin=&quot;anonymous&quot;&gt;
  &lt;/head&gt;
  
  &lt;body id=&quot;main&quot;&gt;
      &lt;h1 class=&quot;heading-first&quot;&gt;Weather App&lt;/h1&gt;
      &lt;h1 class=&quot;heading-second&quot;&gt;+ Random Kanye West Quotes&lt;/h1&gt;
      &lt;hr&gt;
  
      &lt;div class=&quot;container&quot;&gt;
          &lt;div class=&quot;row&quot;&gt;
              &lt;div class=&quot;col-md-6 main-container&quot;&gt;
                  &lt;h1 class=&quot;heading-first&quot;&gt; &lt;%= cityNameFinal %&gt; &lt;/h1&gt;
                  &lt;hr&gt;
                  &lt;h2 class=&quot;heading-third&quot;&gt;Temperature: &lt;%= cityTemperature %&gt; &lt;/h2&gt;
                  &lt;h2 class=&quot;heading-third&quot;&gt;Weather Description: &lt;%= cityDescription %&gt; &lt;/h2&gt;
                  &lt;form action=&quot;/home&quot; method=&quot;POST&quot;&gt;
                      &lt;button class=&quot;our-button&quot; type=&quot;submit&quot;&gt;Search for another City&lt;/button&gt;
                  &lt;/form&gt;
                  &lt;hr&gt;
                  &lt;h2 class=&quot;heading-fourth&quot;&gt; &lt;%= kanyeQuote %&gt; &lt;/h2&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;!-- Bootstrap Scripts CDN --&gt;
      &lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot; integrity=&quot;sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x&quot; crossorigin=&quot;anonymous&quot;&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>