Hello. I need to update one resource multiple times, but each update requires new token. So I need send 2 requests each loop and receive responses in exact order. Trying to use callback something like here:
for (let number of list) {
const Request1 = {
any valid request 1
};
const Request2 = {
any valid request 2
};
if (list !== null && number !== 1) {
pm.sendRequest (Request1, function (err, res) {
if (err) {console.log(err);}
if (pm.expect(res).to.have.property('code', 200)) {
const responce = res.json();
const newToken = response.elearningSessionId;
pm.environment.set("newToken", newToken);
pm.sendRequest (Request2, function (err, res) {
if (err) {console.log(err);}
pm.expect(res).to.have.property('code', 200)
});
});
};
};
But itβs still works randomly (not Loop1: Request1 -> Request2 Loop2: Request1 -> Request2. It works like Loop1:Request1, Loop2:Request1 and then both Requests 2). Code is just example, not working one.
Thanks in advance.