title: How to debug a POST request to a Node.js Express application?
body: <p>I'm new to nodejs and I'm migrating my current API from python to nodejs using express.</p>
  
  <p>What I'm trying to do is to make a request to an external API. I'm pretty sure my API call is right, since I copied from the external API example:</p>
  
  <pre><code>exports.getBalance = function() {
    return new Promise(function(resolve, reject) {
      var command_url = "/v1/transaction/getBalance";
      var full_url = API_URL + command_url;
      var nonce = getNonce();
  
      var data = "username=" + convertUsername(API_USER) + "&amp;nonce=" + nonce;
  
      const signature = makeSignature(nonce, data, command_url);
  
      var form = {
        username: API_USER,
        nonce: nonce
      };
  
      var formData = querystring.stringify(form);
      var contentLength = formData.length;
  
      var headers = {
        "X-API-KEY": API_KEY,
        "X-API-SIGN": signature,
        "X-API-NONCE": nonce,
        "Content-Length": contentLength,
        "Content-Type": "application/x-www-form-urlencoded"
      };
  
      request(
        {
          url: full_url,
          method: "POST",
          headers: headers,
          body: formData
        },
        function(error, response, body) {
          if (!error) {
            body = JSON.parse(body);
            if (response.statusCode == 200) {
              resolve(body);
            } else {
              reject(error);
            }
          } else {
            console.log("error:", error);
            reject(error);
          }
        }
      );
    });
  </code></pre>
  
  <p>This is my express route:</p>
  
  <pre><code>routes.post("/balance", mistertango.getBalance);
  </code></pre>
  
  <p>However, when I try to POST to this route, I don't receive nothing. I use Insomnia to run API tests, so Insomnia keeps running with no response from my express API.</p>
  
  <p>I'd like to know how can I debug my code? I'd like to make an API call using Insomnia to my express API, and check if I'm getting a response from my external API request.</p>
  
  <p>Thanks</p>