Assignment 5 need help passing json response data from scriptHelper to script

I’m having trouble properly passing planetary data from scriptHelper to script.js.

I only get an undefined response, so I’m pretty sure that it’s that I’m not sending what the function wants, if anything at all.

(having read some help threads got me onto that as being the problem)
since passing the json array of planet data into pickPlanet seems to work just fine, that’s how I started. but that’s not what it wants.

So after rereading everything and testing various ways to manipulate my response, I still can’t find a way to actually pass any data at all into the script function that displays the planets in JS per the instructions.

I’ve tried returning json, returning planetsReturned, and lastly now returning the entire response.json().then function because that’s literally what it says to do in the instructions.
No dice, nothing I’ve tried works.
I’ve tried restructuring and rebuilding json object as an array and passing that with the result that it’s not passing anything through. undefined undefined undefined.
I’m feeling incredibly stupid and desperate at this point.

My main question is:
What is it expecting? If I knew what it wanted I could at least hard code something for a test and then work out a solution.

It doesn’t want the one planet because the instructions say that it will populate a list like I can do with an iteration script. it isn’t iterating there, they’re just bare console.logs.

I have listedPlanetResponse set equal to myFetch() per the instructions.

Maybe I have that wrong, but I’ve seen someone doing that already and they seem to be on the right track. What it looks like is that it’s reproducing the fetch line before response.json, so returning the entire response.json function, should just work, but it doesn’t.

It doesn’t work if I pick apart the response.json…then function assigned out to a variable then calling the variable.
I at least figured out that I could separate out the actual promise and response thread that shows it fulfilled before displaying any json data, but that seemed pretty useless too.

I can call everything inside myFetch and build the get the whole thing to display properly and work, but it will never pass the grader lol. I can’t figure out why the data won’t go to the next page over lol.

I can get whatever sending to addDestinationInfo without undefined showing up but there I get the type error that what I’m sending is undefined so I think it’s not really any better.

Also maybe important, both DestinationInfo and formSubmission are giving me reference errors–module not defined which I’m catching,

I’m hoping that’s not contributing anything. I’ve been getting them since I started the assignment and handling the error, so they don’t seem to be doing anything terrible but I’m not sure. FormSubmission works fine so far so not sure why there’s an error there.

So to sum up-what in tarnation does script.JS want?
any and all help appreciated. Thanks for reading!

script.js wants let listedPlanetsResponse = myFetch();

What does your myFetch code look like?

Hi Ryan thank you!

Here is my code:
let listedPlanets; //OC
let listedPlanetsResponse = myFetch(); //OC plus myFetch
console.log(200, listedPlanetsResponse);
listedPlanetsResponse.then(function(result) { //OC
console.log(200.1, typeof(result));
listedPlanets = result; //OC

    console.log(201, listedPlanets); //OC
}).then(function() { //OC
    console.log(203, typeof(listedPlanets)); //OC

OC is for original code, the console logs are me trying to see what’s going on everything returns “undefined”
I thought this would return the json from myFetch, I have very little going on there other than the response.json()…then function retrieving the json data. I’ve tried rebuilding it into an array to be fed in to the HTML a lot like the studio but it doesn’t do much either. My pickPlanet function takes the data and does just fine with it. I’m baffled.
I mean I can console log everything in myFetch and list the planets but the instructions say that it does that in the scripts function right after defining listedPlanetsResponse as myFetch(), and it seems to do the same thing as myFetch except for response.json which I imagine myFetch is supposed to return. SO I set the whole response.json function to return and figured it should work. returning the json value itself or calling it something else and returning it also fails so I’m baffled. I take the exact same data in the function and use it just fine.

Right now my fetch looks like this:
async function myFetch() {
//let json = [];
let planetsReturned;
planetsReturned = await fetch(“”).then(function(response) {
return response.json().then(function(json) {

after that this is what I’m playing with right now going back over everything we did with the homework etc

let random = pickPlanet(json);
console.log(1, random);

        planetsReturned = [];
        let key = 0;
        let index = 0;
        for (json[key].index in json) {

            planet = [
            planetsReturned[key] = planet;

            key = (key + 1) % json.length;


I’m rebuilding the object into an array because that’s what they did in the Studio but same result only now it’s a plain old array

That leads to this readout in the console
known reference error
scriptHelper.js:239 Uncaught ReferenceError: module is not defined
at scriptHelper.js:239
script.js:54 200 Promise
index.html:73 Live reload enabled.
script.js:4 page loaded
scriptHelper.js:128 Array(6)
scriptHelper.js:130 1 Object
scriptHelper.js:147 Array(6)
scriptHelper.js:147 Array(6)
scriptHelper.js:147 Array(6)
scriptHelper.js:147 Array(6)
scriptHelper.js:147 Array(6)
scriptHelper.js:147 Array(6)
scriptHelper.js:151 Array(6)
script.js:56 200.1 “undefined”
script.js:59 201 undefined
script.js:61 203 “undefined”

moving the return statement up and down just changes where the responses render in the console basically