Hello!
I donât know how to create script.
I am stuck with logic.
How i can connect set.newrequest and defining maximum speed.
I checked a lot of data, spent hours but nothing works. Can you help me.
The latest 5th page is not working.
Also I donât know how to define the maximum from 4 requests. I can do it only for 1 page.
Sorry in advance with my bad code and poor English.
var jsonData = JSON.parse(responseBody);
console.log("The number of starships : " + jsonData.count);
pm.test(âStatus code is 200â, function () {
pm.response.to.have.status(200);
});
var page = pm.collectionVariables.get(âpageNumberâ);
pm.collectionVariables.set(âpageNumberâ, page+1);
if (jsonData.next !== null){
let fastestShipName = âMaksimâ;
let fastestShipSpeed = 0;
If youâre struggling with the current challenge it may mean youâre not quite ready for it, and this is completely fine. I would recommend watching this video from Valentin Despa teaching javascript in the context of Postman:
Once youâve learned a bit more you can have another go at the challenge.
Break down your code into steps, so you can clearly see the steps and logic you need to code for (the same as how the tests are broken down in the Galaxy 101 training).
Write the steps first.
Some core logic (Iâm not giving you the full answer as that would defeat the learning exercise).
// test response code
// parse response
// get current speed from collection variable.
// loop though ships setting variables as appropriate.
// if response.next is not null then setNextRequest
TLDR: Break your code into steps, and then learn how to achieve that step.
And as always, the console logs are your friend.
Last point is related to the forum. When pasting code, please use the preformatted text option in the editor as its stops all the code being aligned to the left which is nearly unreadable.
Thank you very much, Jones!
I am very beginner in programming.
Also 9th day is very special to the previous ones: much harder, real challenge!))
Wish you the best!
Thanks for sharing best pieces of advice.