title: How to Render HTTP Post Request result to pug?
body: <p>When a user clicks on the form, I send a http post request to database server. Which in turn sends post request back to user server. </p>
  
  <p>My problem is that I can't post this database result recieved from database server to pug. I am not sure how to implement AJAX here.</p>
  
  <p>I have tried sending the server http request itself, doesn't work. I have also tried to render the results to the pug file in the code as well, not luck!</p>
  
  <p>script.js:</p>
  
  <pre><code>// analyze sentiment button
  function analyzeSentiment() {
      // get and post filter to the backend for sentiment score    
      let form = $("#searchSentiment-form");
        let query = form.serialize();
      console.log(query);
      $.post('/', query);
  }
  </code></pre>
  
  <p>pug file </p>
  
  <pre><code> form#searchSentiment-form(action='javascript:analyzeSentiment()', method='POST')
          input(type="text" id="sentimentFilter" name="sentimentFilter" placeholder="Search a filter" required)
           button(type="submit" id="sentiAnalysis" name="sentiAnalysis") ANALYZE
  </code></pre>
  
  <p>index.js</p>
  
  <pre><code> if(req.body.sentimentFilter) {
          // 1) Convert Tweet into JSON 
          tweetJSON = { sentimentFilter: req.body.sentimentFilter };
          console.log("Analyze this:", tweetJSON)
  
          // 2) Send via HTTP post request to the ANALYSIS-SERVER
          request({
              url: "http://LoadBalancer-1284897978.us-west-2.elb.amazonaws.com",
              method: "POST",
              json: true,   // &lt;--Very important!!!
              body: tweetJSON
          }, function (error, response, body){
            if(error) {
              console.log("HTTP POST: Sending tweets to analysis-server Failed", error);
            } else {
              console.log("Success! Send sentiment request to analysis-server");
              }
            });
  
        //  receiving post result from server with results              
        } else if (req.body.score) {
           let score = req.body.score;
  
             res.render('index', {score:score});
            let JSONscore = { userScore: score};
                 // 2) Send via HTTP post request to the LOAD-BALANCER FOR TWITTER-SERVER
          request({
            url: "http://52.26.216.28:3000",
            method: "GET",
            json: true,
            body: JSONscore
           }, function (error, response, body){
             if(error) {
              console.log("ERROR: COULD NOT SEND SCORE TO OWN USER-SERVER...", error);
  
             } else {
              console.log("SUCCESSFULY SENT SCORE TO OWN USER!..");
             }
          });
  
            console.log("Received Score is ", req.body.score);
  
         } 
  </code></pre>