title: I want to execute my below code as synchronous , by order in nodejs
body: <pre><code>var job = new cronJob('* * * * * *', function () {
      //find and send message using cron job
  
      Quicksms.findOne({
          attributes: ['id', 'phoneno', 'sender', 'message', 'isSent'],
          raw: true
      }).then(data =&gt; {
          console.log('data:', data);
          // var filteredData = datas.filter(data =&gt; data.isSent === 0);
          // console.log('filteredData:', filteredData);
          // for (var i = 0; i &lt; data.length; i++) {
          // if (data.isSent === 0) {
          var uri = '/api/user=test&amp;password=test&amp;sender=' +
              data.sender + '&amp;SMSText=' + data.message + '&amp;GSM=' + data.phoneno;
          var sms = encodeURI(uri);
          var options = {
              host: 'test.com',
              port: 80,
              path: sms,
              method: 'GET'
          };
          http.request(options, function (res) {
              console.log('STATUS: ' + res.statusCode);
              console.log('HEADERS: ' + JSON.stringify(res.headers));
              res.setEncoding('utf8');
              res.on('data', function (chunk) {
                  console.log('BODY: ' + chunk);
              });
          }).end();
  
  
          //update into 1 true:
          Quicksms.update({
              isSent: 'true'
          }, {
              where: {
                  id: data.id
              }
          })
          // }
          //  }
  
  
          //store in log
          QuicksmsLog.create({
              phoneno: data.phoneno,
              sender: data.sender,
              message: data.message,
              isSent: data.isSent
          }).then(function (data) {
              if (data) {
                  console.log("successfully stored in log");
              } else {
                  console.log("failed");
              }
          })
  
  
          //destroy message after sending
          Quicksms.destroy({
              where: {
                  isSent: 1
              }
          }).then(delData =&gt; {
              console.log('cronJob deleted successfully.', delData);
          });
      });
  }, function () {
      console.log('DelCron Job finished.');
  }, true, 'Asia/Calcutta');
  </code></pre>
  
  <p>Above code is working as async order
  Async order :</p>
  
  <p>1.Quicksms.findone</p>
  
  <p>2.Quicksms.Delete</p>
  
  <p>3.Quicksms.Update</p>
  
  <p>4.Quicksmslogs.Create</p>
  
  <p>This one working as async , i want to work this functions as order !</p>
  
  <p>How to do that  in synchronous way? help me</p>
  
  <p>What is the use of async task? in nodejs, I am a newbie! help me.</p>