Still stuck with MCV data object import export

I am using MCV I have my data in a state array with other objects nested inside. I got my data to go from controller to view. When I console log the data in the view it shows all the correct objects, nested object data. When I try being more specific with my console log to a specific nested object it shows it is empty. The same thing happens when I lob both in the controller. But when I log it in the model it shows up fine. There is data in the nested objects when I just log the parent object. But not when i log the parent.nested object.
24 Replies
MarkBoots
MarkBoots3y ago
where are you calling _generateMarkup? Are you sure the data is fetched before you call that method? forget that, I can't read apperenty can we see the whole class?
Errtu
Errtu3y ago
Thank you for the response Mark! https://github.com/bsupinski/weather_app haha its I need to work on asking quests better.
GitHub
GitHub - bsupinski/weather_app
Contribute to bsupinski/weather_app development by creating an account on GitHub.
Errtu
Errtu3y ago
model has empty state, and the fetch request. Controller has the fetch request, then calls the class method with the fetch data. View has the method.
MarkBoots
MarkBoots3y ago
hmm, can not find it. i have the feeling somewhere you're not awaiting for the data to be fetched completely
Errtu
Errtu3y ago
I been trying that. I just cant wrap my head around, if I log state.model it shows data in the location obect inside. If I log state.model.location it is empty.
MarkBoots
MarkBoots3y ago
yea, this is really strange. ive download it
Errtu
Errtu3y ago
I narrowed it down to the geolocation being the issue. I fetched the api without it. using a zip code, all the data got passed
MarkBoots
MarkBoots3y ago
i have the feeling that the data object is empy at first (but after logging it gets filled) because when seeing this, it looks like they are empty (if there is something in those keys, there should be something visable indicating they are not empty
MarkBoots
MarkBoots3y ago
MarkBoots
MarkBoots3y ago
only after expending, it shows data (filled later?)
Errtu
Errtu3y ago
I am seeing {...}
Errtu
Errtu3y ago
which means data inside?
MarkBoots
MarkBoots3y ago
could be difference of browser. But i think you should do a promise on the filling of those objects, before rendering it
Errtu
Errtu3y ago
with a new Promise?
MarkBoots
MarkBoots3y ago
i have to dive a bit deeper in to it... it's really strange, and have to figure out your structure a bit more not really experienced with oop, so have to find my way a bit
Errtu
Errtu3y ago
is the structure trash?
MarkBoots
MarkBoots3y ago
not saying that.
Errtu
Errtu3y ago
await model.loadWeather("02816"); Using that instead of running the load weather threw the geolocation worked. through
MarkBoots
MarkBoots3y ago
unfortunatly im not really in the oppertunity to deep dive in to it right now. I asked for some more experts. Hopefully someone can figure it out sooner. Otherwise i'll try it later when i have more time
Errtu
Errtu3y ago
I appreciate the help, thank you @MarkBoots
MarkBoots
MarkBoots3y ago
i've send you something with dm
Errtu
Errtu3y ago
Update Still no fix but have figured out the data works when logged in the geolocation, so the issue happens when the geolocation is being called in the loadUserWeather function. And the console log in the geolocation happens 2nd. So it is a async issue.
Errtu
Errtu3y ago
So line 11 should be happening before 25 but something is missing to make the geolocation call to wait.
Errtu
Errtu3y ago
Was able to get it to work by making the main call the geolocation function the main call function, instead of a seperate calling geolocation then the fetch. I am not sure if it a proper fix for it, but it lets me work on the views while I try finding a better solution if there is one.
Want results from more Discord servers?
Add your server