Uncaught (in promise) TypeError: data.forEach is not a function at index.html:25:18 [duplicate]

try {
  async function getPlanets() {
    let response = await fetch('https://swapi.py4e.com/api/planets/');
    let data = await response.json()
    return data;

  }
} catch (error) {
  error = console.log(error);
}
getPlanets().then(data => {
  data.forEach(planet => {
    const markup = `<li>${planet.name}</li>`;
    document.querySelector('ul').insertAdjacentHTML('beforeend', markup);
  });
});

the above code is throwing the error shown in the title, ive done some googling and I honestly just think ive been staring at this too long and need a second opinion, any thoughts on why it would do this? I kind of think its because the swapi is not returning an array so forEach isnt allowed, but if thats the case how do i get it to grab the array? because it is there i saw it in the console earlier its an array with 10 planets in it however its property is called “result” is this where I went wrong?

apologies if this was a bad question I am still new to this stuff and practical exercises seem to help BUT I BE STUCK ATM!

I tried looking through documentation, however I was following a short video on making an API call and then displaying that info to your webpage, but then it threw the error and at this point I feel like I’m just thinking about it the wrong way and its a simple fix.

I think it has something to do with the response being an object and not an array but again if that’s the case how do I grab the “result:” array so I can loop through it and display the planet name that’s the question at the very top