title: NodeJS Running multiple fetch requests inside multiple Node-Schedule jobs
body: <p>My goal is to be able to run different functions in each of the multiple node schedule jobs, which will run at specific times of the day, and will call a specific function depending on the time of the day.</p>
  <p>I have the following code, for a minimum example I have made it simple.</p>
  <pre><code>var f1 = function () {
      return fetch('url1.php', {
          method: 'post',
          headers: {
              'Content-Type': 'application/json'
          }
      })
  }
  
  var f2 = function () {
      return fetch('url2.php', {
          method: 'post',
          headers: {
              'Content-Type': 'application/json'
          }
      })
  }
      var tasks = [f1, f2];
  
  const promesas = async(tasks) =&gt; {
  return await Promise.all(tasks.map(function (e, j) {
  
  rules[j] = new schedule.RecurrenceRule();
  rules[j].dayOfWeek = [new schedule.Range(1, 5)];
  rules[j].hour = hours[j];
  rules[j].minute = mins[j];
  
  return schedule.scheduleJob(rules[j], async function () {
      try {
          await tasks[j]()
          
      } catch (error) {
          console.log(error);
      }
  });
  })).then(response =&gt; {
      return Promise.resolve(response);
      });
  }
  
  promesas(tasks);
  </code></pre>
  <p>I can run these functions just fine outside the jobs, or all within a single job. But not in the setup that I want which I describe at the beggining.</p>
  <p><strong>The first iteration works fine</strong>, the second just fails. The difference between each job is of one minute for testing purposes.</p>