DEV Community

Discussion on: Beginners Guide To Fetching Data With (AJAX, Fetch API & Async/Await)

Collapse
 
eripanci profile image
Eri Pançi

since I'm working on Glitch, here is the full project: glitch.com/edit/#!/titanium-freeze

As you can see, inside the function getMovies it's async function and getData(). Can I make these two not inside one function but instead in two? One can get the data, the other can show it?

Thank you.

Thread Thread
 
bjhaid_93 profile image
/[Abejide Femi Jr]\s/ • Edited

Can't access that URL, can you paste your code here please, or possibly push to GitHub and send the URL

Thread Thread
 
eripanci profile image
Eri Pançi

Strange. Anyway here it is in Github: github.com/erip2/MovieApp/

Thread Thread
 
bjhaid_93 profile image
/[Abejide Femi Jr]\s/ • Edited

firstly, what are the datas you are trying to get from the API, i can also see you are trying to persist to sessionstorage, es6 classes could make the code look cleaner a bit tho, have a separate class for your ui, another class for you Session or local storage, then another class for the Movie.

Thread Thread
 
eripanci profile image
Eri Pançi

The data I'm getting from API is an array of movie titles the user search. Then when user clicks for details, I save the movie ID in sessionStorage to open a new window with that movie details.

That was exactly why I asked, to do these in different places in my code. Could I do these in different objects or should I read about JS classes since I don't know them very well to use it?

Thanks again.

Thread Thread
 
bjhaid_93 profile image
/[Abejide Femi Jr]\s/

sorry for the late reply, can you check this out github.com/abejide001/Github-profi....