title: Postman hangs (keeps loading) on sending a request to an express route
body: <p>I created this api that generates a connection request between two user (similar to linkedin or any other social media)</p>
  <pre><code>/**
   * sendRequest
   * * Send request to a user
   * TODO: Testing required
   * @param {string} from username of request send from
   * @param {string} to username of request send to
   */
  User.sendRequest = (from, to) =&gt; {
    return new Promise((resolve, reject) =&gt; {
      const userId = 0;
      const friendId = 0;
  
      User.findByUsername(from)
        .then((data) =&gt; {
          userId = data.id;
          console.log(data);
          User.findByUsername(to)
            .then((data) =&gt; {
              friendId = data.id;
              Connects.checkConnectionStatus(from, to)
                .then((areFriends) =&gt; {
                  if (!areFriends) {
                    const connects = new Connects({ userId, friendId });
                    console.log(connects);
                    Connects.create(connects)
                      .then((data) =&gt; resolve(data))
                      .catch((err) =&gt; reject(err));
                  } else {
                    const newError = new Error(
                      `Users ${from} and ${to} are already connections`
                    );
                    newError.status = 400;
                    return reject(newError);
                  }
                })
                .catch((err) =&gt; {
                  console.log(`Error: ${err}`);
                  return reject(err);
                });
            })
            .catch((err) =&gt; {
              if (err.status &amp;&amp; err.status === 404) {
                reject(err);
              }
            });
        })
        .catch((err) =&gt; {
          if (err.status &amp;&amp; err.status === 404) {
            reject(err);
          }
        });
    });
  };
  </code></pre>
  <p>Here I am first checking if provided userids are valid of not.
  I am using a model User that provides me facility to check if user exists with userid by findByUsername() function.</p>
  <p>I checked each model individually, the are working. But On sending request on above route, postman keeps on loading. Please let me know solution.</p>
  <p>Find by username model:</p>
  <pre><code>/**
   * findByUsername
   * * Finds a user by username
   * @param {string} username username whose detail needed to find
   */
  User.findByUsername = (username) =&gt; {
    return new Promise((resolve, reject) =&gt; {
      const query = `
              SELECT 
                  u.*, p.* 
              FROM user u INNER JOIN profile p 
              ON u.username = p.username 
              WHERE u.username = ?
          `;
      sql.query(query, username, (err, res) =&gt; {
        if (err) {
          console.log(`Error: ${err}`);
          return reject(err);
        }
        if (!res.length) {
          const newError = new Error(`User with username ${username} not found`);
          newError.status = 404;
          return reject(newError);
        }
        console.log(`Found user: `, res);
        resolve(res[0]);
      });
    });
  };
  </code></pre>
  <p>Connects constructor:</p>
  <pre><code>// constructor
  const Connects = function (connect) {
    this.userId = connect.userId;
    this.friendId = connect.friendId;
    this.status = 1;
  };
  </code></pre>
  <p>Method for creating connect:</p>
  <pre><code>/**
   * create
   * * Creates a new connection request between two users
   * @param {object} newConnect A connection object
   */
  Connects.create = (newConnect) =&gt; {
    console.log(newConnect);
    return new Promise((resolve, reject) =&gt; {
      const query = &quot;INSERT INTO connects SET ?&quot;;
      sql.query(query, newConnect, (err, res) =&gt; {
        if (err) {
          console.log(`Error: ${err}`);
          return reject(err);
        }
        const response = { id: res.insertId, ...newConnect };
        console.log(`Created connect: `, response);
        resolve(response);
      });
    });
  };
  
  </code></pre>
  <p>THIS IS ROUTE:</p>
  <pre><code>// TODO: Send request
  router.post(
    &quot;/request&quot;,
    [body(&quot;from&quot;).not().isEmpty().escape(), body(&quot;to&quot;).not().isEmpty().escape()],
    (req, res, next) =&gt; {
      // Finds validation errors and return error object
      const errors = validationResult(req);
      if (!errors.isEmpty()) {
        return res.status(400).json({ errors: errors.array() });
      }
      const { from, to } = req.body;
  
      if (from === to) {
        const newError = new Error(&quot;Equal input is not allowed&quot;);
        newError.status = 400;
        next(newError);
      } else {
        User.sendRequest(from, to)
          .then((data) =&gt; res.json(data))
          .catch((err) =&gt; next(err));
      }
    }
  );
  </code></pre>
  <p>POSTMAN BEHAVIOUR:
  <a href="https://i.stack.imgur.com/8FUHp.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8FUHp.jpg" alt="enter image description here" /></a></p>