title: Node JS EJS get URL parameters
body: <p>I'm trying to read URL parameters in an EJS template, however everything I try or read from google isn't working. Here's the relevant part of my app.js file:</p>
  
  <pre><code>app.post('/account/logintoaccount', function(req, res) {
      var email = req.body.email;
      if(email === '') {
          res.redirect('https://myurl.com/account/login?e=bademail');
          return;
      }
      var password = req.body.password;
      if(password === '') {
          res.redirect('https://myurl.com/account/login?e=badpassword');
          return;
      }
      res.redirect('https://myurl.com/?email=' + email + '&amp;pw=' + password);
  });
  </code></pre>
  
  <p>And here's where I'm trying to display the variable in my EJS file:</p>
  
  <pre><code>&lt;div id="title-text"&gt;
      &lt;% if(!req.query.e) { %&gt;
          &lt;p&gt;Log into your account:&lt;/p&gt;
      &lt;% } else if(req.query.e === "badpass") { %&gt;
          &lt;div class="alert alert-danger"&gt;&lt;strong&gt;Error&lt;/strong&gt; incorrect password&lt;/div&gt;
      &lt;% } else if(req.query.e === "bademail") { %&gt;
          &lt;div class="alert alert-danger"&gt;&lt;strong&gt;Error&lt;/strong&gt; unknown email address&lt;/div&gt;
      &lt;% } %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>If I remove this part of my EJS file my redirects work fine. The URL has the parameters in it and all is good. However whenever I try and use my URL parameters in any way shape or form in my EJS file it breaks and gives me an "X is undefined error". I've tried using 'e', 'req.query.e', 'this.e', 'this.req.query.e' and anything else that google results have suggested I do.</p>
  
  <p>My end goal is to be able to read the URL parameters in <a href="https://myurl.com/account/login?e=somethinghere" rel="nofollow noreferrer">https://myurl.com/account/login?e=somethinghere</a></p>
  
  <p>Then check what 'e' holds. I've spent the last 30+ minutes reading over google results however I believe they're either outdated or I'm just doing them wrong. Can anyone help please? Thank you for your time</p>