title: AWS Lambda not calling third party api in loop
body: <p>i am using aws lambda and i am calling third party server using request library. this library on outside the loop but on loop its not hitting even i am not getting any error or result. and i also checked on server there is no hitting
  below is my code with console</p>
  <pre><code>
  exports.handler = async (event) =&gt; {
      try {
          let transactionList = [];
          // event.body is json form object with keys and values that we send
          userBrokers.forEach(async (brokers) =&gt; {
              const userStocks = 50;
              const qty = (qtyPercentage * userStocks) / 100;
              console.log(&quot;function before api call&quot;)
              request.post({
                  headers: {
                      'content-type': 'application/x-www-form-urlencoded',
                      &quot;Apca-Api-Key-Id&quot;: brokers.api_key,
                      &quot;Apca-Api-Secret-Key&quot;: brokers.secret_key
                  },
                  url: 'https://paper-api.alpaca.markets/v2/orders',
                  json: {
                      symbol,
                      qty,
                      side: orderType,
                      type: marketType,
                      time_in_force
                  }
              }, function (error, response, body) {
                  if (error) {
                      console.log(&quot;api call error&quot;)
                      transactionList.push({
                          transactionSuccess: false,
                          reason: error,
                          userId: brokers.user_id,
                          documentId: brokers._id
                      })
                  }
                  else {
                      console.log(&quot;api response&quot;)
                      if (response.statusCode == 200) {
                          transactionList.push({
                              brokerOrderId: body.id,
                              symbol: body.symbol,
                              orderType: body.order_type,
                              marketType: body.side,
                              transactionSuccess: true,
                              userId: brokers.user_id,
                              documentId: brokers._id
                          })
                      }
                      else {
                          transactionList.push({
                              transactionSuccess: false,
                              reason: body.message,
                              userId: brokers.user_id,
                              documentId: brokers._id
                          })
                      }
                  }
              });
          })
      console.log(&quot;function before response&quot;)
      return {
          statusCode: 200,
          body: JSON.stringify(transactionList),
      };
  } catch (error) {
      console.log(&quot;function catch block&quot;)
      return {
          statusCode: 200,
          body: JSON.stringify(error.message),
      };
  }};
  
  </code></pre>
  <p>and i get below console.</p>
  <pre><code>function before api call
  function before response
  </code></pre>
  <p>and response from lambda
  status: 200 and message: []</p>