title: Express.js: res.render() does not send data when wrapped in promise chain
body: <p><strong>I recently started refactoring older callback-hell routes to use promises.</strong> <em>(Note: the refactor is not complete so some of the following code is ugly)</em></p>
  
  <p>Doing so broke my <code>res.render()</code> function. </p>
  
  <ul>
  <li>I am using EJS for my render engine.</li>
  <li>Most of my promise chains are built off of MongoDB / Mongoose queries.</li>
  </ul>
  
  <p>The basic app structure is a complex survey / quiz that sorts users into different categories. It stores their info and renders a custom EJS page at the end. Here's how the final call works, basically:</p>
  
  <pre><code>         mongoose.model('Result')
               .findOne({quizId: req.query.id})
               .then(getPageData)
               .then(renderPage)
               .catch(errorHandler)
  </code></pre>
  
  <p>Simple enough, in theory. </p>
  
  <p>Relevant functions:</p>
  
  <pre><code>    let getPageData = (mongooseResult) =&gt; {
  
        let resultsPage;
        let analyticsData;
  
        if (mongooseResult.answers.section1.question1.answer != null &amp;&amp; mongooseResult.answers.section1.question1.answer != undefined){
            let resultsPage = WP.getPage(wp_pages_data, 'slug', mongooseResult.coreFit);
            let analyticsData = {
              quizId: mongooseResult.quizId,
              coreFit: mongooseResult.coreFit,
              secondFit: mongooseResult.secondFit,
              degree: mongooseResult.answers.section1.question1.answer,
              year: mongooseResult.answers.section1.question2.answer,
              concentration: mongooseResult.answers.section1.question3.answer,
              views: mongooseResult.views,
            }
  
          mongooseResult.views++;
          mongooseResult.save();
  
          return [resultsPage, analyticsData, mongooseResult];
        } else {
          throw new Error('S1Q1 IS UNDEFINED');
        }
      };
      let renderPage = ([resultsPage, analyticsData, mongooseResult]) =&gt; {
        if (resultsPage != null &amp;&amp; resultsPage != undefined){
  
          // WHY IS MY RENDER NOT WORKING???
          res.render('templates/' + mongooseResult.coreFit,  Object.assign({}, WP.get_WP_data(resultsPage), getPartials(mongooseResult.modules), analyticsData), (err, html) =&gt; {if (err) console.log(err); else res.send(html);});
        } else {
          throw new Error('GETTING PAGE DATA RETURNED UNDEFINED');
        }
      };
  </code></pre>
  
  <p>Incoming requests are first routed to a <code>/submit</code> POST route - which manipulates some data, stores it all in the DB, then does <code>res.redirect()</code> to the <code>/results?id=12345</code> GET route, which runs the logic above. </p>
  
  <p>What's funky is that the <code>render()</code> actually fires; the callback ( <code>(err, html) =&gt; {if (err) console.log(err); else res.send(html);}</code> ) sends rendered HTML to IF YOU HIT THE ROUTE A SECOND TIME. </p>
  
  <p>Completing the survey does NOT generate a response; but it DOES successfully store all our info in the DB and console.logs the ID to which the client request should redirect. Hitting the GET route with this generated ID / URL, literally by copy-pasting it, renders just fine.</p>
  
  <p>Swapping the render for a simple <code>res.send('wtf')</code> works - an actual response is sent to the client. <em>(in this case the string 'wtf' ... )</em></p>
  
  <p>The response just doesn't send back data. I don't get it. Any ideas?</p>
  
  <p><strong>UPDATE:</strong>
  Strangely enough, hitting the route manually vs the redirect from my earlier POST request produce different results with a simple <code>res.send('wtf mate')</code>. </p>
  
  <p><em>Hitting the GET route and passing in a previously existing ID to the req.query manually:</em><a href="https://i.stack.imgur.com/SzsfG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SzsfG.png" alt="enter image description here"></a></p>
  
  <p><em>Hitting the GET route AFTER the <code>res.redirect()</code> call from the prior POST request:</em><a href="https://i.stack.imgur.com/Nogus.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Nogus.png" alt="enter image description here"></a></p>
  
  <p>This might be more an Express request type mismatch issue? Why would a <code>res.redirect('/results?id=someString')</code> call mutate the URL vs sending back a string / HTML?</p>