title: Delay response for a GET call in nodejs with Express
body: <p>I have two APIs written in Nodejs and Express. Lets call them API1 and API2. API1 queries a DB and gets an ID from this DB. Then API1 performs a GET call to API2 with the ID in it. Then API2 captures this ID and performs its own operations ahead. It is a recursive procedure for each ID. So one GET request for each ID from API1 to API2</p>
  <p>But what happens is since I have a lot of IDs, before all of them perform the GET request from API1 to API2, I get a 504 timeout as expected since my API1's GET request does not get any response back.</p>
  <p>My question is how can I delay this 504 request timeout that I get in API1 before all my IDs make a request to API2?</p>
  <p>Heres the example code from API1:</p>
  <pre><code>router.get('/getIds', (req, res) =&gt; {
      getIDsFromDB();
    });
  
  
  getIDsFromDB() {
  //ids here below is an array of all id's I get from querying my DB
  // Example of how ids would look: ids = [{ID:&quot;1234567890&quot;}, {ID:&quot;0987654321&quot;}]
  ids.map(Id =&gt; {
          let recordId = Id['ID'];
          makePostToAPI2(recordId).then().catch(err =&gt; {
              //To check error
              console.log(err);
          });
      });
  }
  
  makePostToAPI2(recordId){
  //I use request-promise npm library to make the request to API2
  let url = API2URL + recordId;
      return  rp({
          uri: url,
          method: 'GET',
          json: true
      });
  }
  </code></pre>