The requests in pre-req script are not sent in sequence

I am sending three requests in pre-req for authenticating the user and getting the access token.

The way i am sending the requests is:

const codeGetRequest = {
url: pm.variables.get(‘test-code-url’),
method: ‘GET’
};

pm.sendRequest(codeGetRequest, function (err,res){
if(//some condition){
console.log(‘No Code found. User should sign in.’);
}

else{
    //sending a second GET request
}

});

//Sending a third request (POST) here

The issue i am facing is that the the second GET request is getting sent after the third(POST) request when checked in console.

Please advise if i am doing something wrong here.
NOTE: all the request are getting sent but not in the sequence it is written.

These calls are sent asynchronously, meaning they aren’t going to wait . If you need them in order you’re going to have to put them in the callbacks.

const codeGetRequest = {
url: pm.variables.get(‘test-code-url’),
method: ‘GET’
};

pm.sendRequest(codeGetRequest, function (err,res){
  if(//some condition){
    console.log(‘No Code found. User should sign in.’);
  }
  else{
    pm.sendRequest('second request', function(err, res){
      if(res){
        //Send the third request
      }
    }
  }
});