The expected output in the response body is just name of starships like “name”: “CR90 corvette”, “name”: “Droid control ship” and so on… by passing an API. Is it possible?
I wrote the below script in Tests:
let jd=pm.response.json()
let cs= jd.results[0].starships[0];
console.log(cs);
As you know it will display only the URL not the name.
You could do something like this in the Test tab, once you received the response from the /films endpoints, use pm.sendRequest() to loop through the starships array and extract the names from the responses to the console.
let starships = pm.response.json().results[0].starships;
starships.forEach(function(starship){
pm.sendRequest(`${starship}`, function (err, res) {
if(err) { throw err}
console.log(res.json().name);
});
});
There are a number of different ways that you can get the name but as this question is quite vague and seems to be part of an assignment - You’re better off just posting the course question to get a more targeting solution.
I would advise taking a closer look at sites like JavaScript Tutorial to get a better understanding of basic Javascript, which will help you when trying to present the data in different ways.