title: How to do a multiple Post Requests in Node js
body: <p>Hello I want to do multiple post requests based on some conditions. I am trying but my code isn't working. I have a database stored online(Firebase). What I do is I fetch the data from online and save into localdb and then delete the online data. </p>
  
  <p>This is what I am doing so far</p>
  
  <pre><code>request('http://my-url here', function (error, response, body) {
      console.log('error:', error);
      console.log('statusCode:', response &amp;&amp; response.statusCode); Print the response status code if a response was received
  
      var data = [];
      var parse = JSON.parse(body);
  
      var ids =  Object.keys(parse);
       var i = 0;
  
     ids.forEach(function(id) {
     var unique_keys =  Object.keys(parse[id]);
          unique_keys.forEach(function(unique_key) {
  
              data[i] = [
  
                      parse[id][unique_key]["lat"],
                      parse[id][unique_key]["long"],
  
  
  
                  ];
                  i++;
     });
  
   });
  
      saveHistory(data, function (result) {
  
          console.log("successfully save into local db");
          removeDataFromOnlineDatabase
          process.exit();
  
      });
  
  
  
  
  
  }); 
  
  function removeHistoryFromOnlineDatabase(){
  
      var request = require("request");
  
     console.log("function get called");
      var options = { method: 'DELETE',
          url: 'url here',
          headers:
              { 'Postman-Token': '4a126ab8-9b3e-465d-b827-d4dd83923610',
                  'Cache-Control': 'no-cache',
                  'Content-Type': 'application/json' } };
  
      request(options, function (error, response, body) {
          if (error) throw new Error(error);
  
          console.log("history has been removed" + body);
      });
  
  }
  </code></pre>
  
  <p>I have tried this above code but this  function <code>removeHistoryFromOnlineDatabase</code> post request don't work </p>
  
  <p>the function get called and it prints "function get called" But it doesn't print "history has been removed"</p>