title: Getting an AJAX GET request to work with Express.js
body: <p>I am using node.js and Express.js on the back end, and am trying to make a server call from the client via AJAX.</p>
  
  <p>So I have this POST request that works fine with AJAX:</p>
  
  <p><strong>node.js/Express.js:</strong></p>
  
  <pre><code>app.post('/createNewThing', function(req, res) {
      var userInput = req.body.userInput;
      if (userInput) {
          res.send('It worked!');
      }
  });
  </code></pre>
  
  <p><strong>Client Side/AJAX request:</strong></p>
  
  <pre><code>var userInputForm = $('#userInputForm.val()')
  $.ajax({
      url: "/createNewThing",
      type: "POST",
      data: "userInput=" + userInputForm,
      dataType: "text",
          success: function(response, status, http) {
              if (response) {
                  console.log('AJAX worked!);
              }
          }
      });
  </code></pre>
  
  <p>The <code>userInputForm</code> comes from an HTML form.</p>
  
  <p>This POST request works fine. But I want to change this to a GET request. If I change <code>app.post</code> to <code>app.get</code>, and change <code>type</code> in the AJAX call to <code>GET</code>, I get this 500 error: </p>
  
  <p><code>GET /createNewThing?userInput=</code> <code>500</code></p>