The fetch request seems to return empty data when used in web and erroneous data when used in android or iOS. I just need it to work in web. I currently get it displaying empty jsons although I did manage to have it work once but couldn’t replicate it.
It should be displaying this:
I’m taking part in an online course CS50M and part of this is for my project.
Hi Patrick! Thanks for the example. It looks like you are returning a Promise from
getSearchResults (it’s an async method) This means you also have to wait for the promise to resolve in
componentDidMount. I made a little demo how to do such things with React’s state.
Hope it helps
Thank you, I managed to fix the problem. I think you’re right about my bad use of async.
Another issue I ran into was using http instead of https. Even though the request in a regular browser works fine with http, it doesn’t always work with snack.
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.