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
_generateMarkup?
Are you sure the data is fetched before you call that method?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.
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.
hmm, can not find it. i have the feeling somewhere you're not awaiting for the data to be fetched completely
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.
yea, this is really strange. ive download it
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
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
only after expending, it shows data (filled later?)
I am seeing {...}
which means data inside?
could be difference of browser. But i think you should do a promise on the filling of those objects, before rendering it
with a new Promise?
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
is the structure trash?
not saying that.
await model.loadWeather("02816");
Using that instead of running the load weather threw the geolocation worked.
through
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
I appreciate the help, thank you @MarkBoots
i've send you something with dm
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.
So line 11 should be happening before 25 but something is missing to make the geolocation call to wait.
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.