Here is my code
let url;
let planetCount;
let planetData = [];
//turn through the pages
for (let p = 1; p < 7; p++) {
url = `https://swapi.boom.dev/api/planets?page=${p}`;
//fetch data
for (let j = 0; j < 1; j++) {
fetch(url).then(res => res.json())
.then(data => {
//push data to array
for (let i = 0; i < data.results.length; i++) {
planetData.push(data.results[i]);
}
})
console.log(planetData)
}
}
And here is the output: https://i.stack.imgur.com/Hivwr.png
Problem: How do I make it so it all goes into one array, instead of 6?