title: Is there way to have Node redirect to a new page with JSON?
body: <p>I'm trying to allow users to type a search query into a box on an index.html page and have it send them to a results.html page with results displayed.</p>
  
  <p>Currently I have this working only on an index.html page where the old HTML is removed and replaced with the search results.</p>
  
  <pre><code>//Pertinent Node code:
  
      app.get('/', function(req, res){
      res.header("Access-Control-Allow-Origin", "*");
  
      res.redirect('index.html');
  
  });
  
  // A search box in index.html calls the /search below
  
  app.get('/search', function (req, res) {
      res.header("Access-Control-Allow-Origin", "*");
      const item_id = req.query.item_id;
      var json = {};
  
      var sql_query = "a SQL query";
  
      var result = connection.query(sql_query, function(err, result,         fields) {
          if (err) throw err;
          json["result"] = result;
  
          console.log("Sent JSON to client");
          res.send(JSON.stringify(json));
      });
  })
  
  //Client-side:
      function get() {
          var search = document.getElementById("search").value;
  
          // Validate input to prevent injections
          var new_search = search.replace("&lt;", "");
          var validated = new_search.replace("&gt;", "");
  
          var url = host + "/search?search=" + validated;
  
          fetch(url, {method : 'GET'})
  
              .then(checkStatus)
              .then(function(responseText) {
                  var json = JSON.parse(responseText);
                  displaySearchResults(json, search);
              })
  
              .catch(function(error) {
              });
      }
  </code></pre>
  
  <p>What I'm trying to do is similar to what you might see on Google where clicking search send you to a new page with a url like: "<a href="https://www.google.com/searchresults?query=bicycles" rel="nofollow noreferrer">https://www.google.com/searchresults?query=bicycles</a>" that displays a different HTML page from index.html (such as results.html) with the JSON from index.html being moved to and processed in results.html.</p>
  
  <p>How can I make this happen?</p>