title: Search functionality with Node JS & MySql?
body: <p>I am attempting to add a search functionality with my database using Node &amp; Handlebars to render. However when I search now it's giving me a 404 error, why is it not display search results? Here is my routing info</p>
  
  <pre><code>        function searchPokemon(res, mysql, context, searchinput, complete){
          var inserts = [req.body.searchinput];
          var sql = 'SELECT pokemonname FROM pokemon WHERE pokemonname LIKE "%' + inserts + '%';
          mysql.pool.query(sql, inserts, function(error, results, fields){
                  if(error){
                          res.write(JSON.stringify(error));
                          res.end();
                  }
                  context.search = results;
                  complete();
                  });
          }
  
  
     router.get('/search', function(req, res){
          callbackCount = 0;
          var context = {};
          var mysql = req.app.get('mysql');
          searchPokemon(res, mysql, context, req.body.searchinput, complete);
          function complete(){
                  callbackCount++;
                  if(callbackCount &gt;= 1) {
                          res.render('search-pokemon', context);
                  }
          }
  });
  </code></pre>
  
  <p>Here is my current page that I am rendering the search functionality on (pokemon.handlebars)</p>
  
  <pre><code>&lt;h1&gt;Current Pokemon Moves -&lt;/h1&gt;
  
  &lt;table id="table"&gt;
      &lt;thead&gt;
          &lt;th&gt;Pokemon Name &lt;/th&gt;
          &lt;th&gt;Evolution Level   &lt;/th&gt;
          &lt;th&gt;Move Name   &lt;/th&gt;
          &lt;th&gt;Strength&lt;/th&gt;
      &lt;/thead&gt;
     &lt;input type="text" class="search form-control" name="searchinput" placeholder="Pokemon Name"&gt;
     &lt;input type="button" class="btn btn-primary" value="Search" onclick="getUsers({{searchinput}})"&gt;
          &lt;br&gt;
  </code></pre>
  
  <p>And here is my script to search </p>
  
  <pre><code>function getUsers(searchinput){
          $.ajax({
                  url: '/search-pokemon',
                  type: 'GET',
                  success: function(result){
                          window.location.reload(true);
                  }
          })
  };
  </code></pre>