Open
Conversation
haaspt
commented
Oct 5, 2021
|
|
||
| origins = ["http://localhost", "http://localhost:3000"] | ||
|
|
||
| app.add_middleware( |
Member
Author
There was a problem hiding this comment.
The frontend is technically located at a different origin so we have to enable CORS so the requests will be allowed. More here.
haaspt
commented
Oct 5, 2021
| // TODO: Add isError state handling | ||
| } | ||
| ) | ||
| }, [locationData]); |
Member
Author
There was a problem hiding this comment.
useEffect accepts a final argument that describes its dependencies. Anytime a dependency is updated the effect will run again. In this case we just need this to run once when the container mounts so we shouldn't have any dependencies. However, since we're using locationData in our API call we need to include it as a dependency (even if we don't expect it to change inside the container)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR replaces the placeholder weather forecast data in the frontend with actual data fetching from the backend.
To accomplish this I added a
/forecast/endpoint to the backend. Currently it just randomly generates a list of conditions and temperatures regardless of what location is queried.The frontend static data has been replaced with an async
fetchcall inWeatherForecast.js. This also involved adding additional states to store the data and the loading status.How to Test
localhost:8000/docsand test out the new endpointlocalhost:3000and observe how weather data is dynamically populated