Open
Conversation
| }) | ||
| .then((res) => res.json()) | ||
| .then((data) => addWeatherData(data)); | ||
| // .then((data) => console.log(data)); |
|
|
||
| // Function that grabs the coordinates to be used later by fetchWeather to generate weather data | ||
| const fetchGeoLocationData = (searchLocation) => { | ||
| const geolocationURL = `https://api.openweathermap.org/geo/1.0/direct?q=${searchLocation}&appid=${apiKey}`; |
There was a problem hiding this comment.
Good you didn't commit your API but it should have been as an environment variable, its crashing your app.
Comment on lines
+3
to
+4
| let cityWeather = []; | ||
| let forecastWeather = []; |
Comment on lines
+25
to
+26
| let lat = data[0].lat; | ||
| let lon = data[0].lon; |
Comment on lines
+23
to
+24
| .then((res) => res.json()) | ||
| .then((data) => { |
There was a problem hiding this comment.
be more clear with the argument naming.
Suggested change
| .then((res) => res.json()) | |
| .then((data) => { | |
| .then((serverData) => serverData.json()) | |
| .then((parsedData) => { |
| }); | ||
|
|
||
| // Function that grabs the coordinates to be used later by fetchWeather to generate weather data | ||
| const fetchGeoLocationData = (searchLocation) => { |
| }; | ||
|
|
||
| // Convert Kelvin to Fahrenheit | ||
| const convertKelvinToFahrenheit = (kelvin) => { |
There was a problem hiding this comment.
wrong argument and function name. Be more precise.
Suggested change
| const convertKelvinToFahrenheit = (kelvin) => { | |
| const convertTemperatureFromKelvinToFahrenheit = (kelvinTemperature) => { |
Comment on lines
+66
to
+69
| temp: convertKelvinToFahrenheit(data.main.temp), | ||
| name: data.name, | ||
| condition: data.weather[0].main, | ||
| icon: data.weather[0].icon, |
There was a problem hiding this comment.
all of these will crash if data is undefined. Your code will fail compile and silently crash to the user.
Use ? to avoid this and handle error
| renderCurrentWeather(cityWeather); | ||
| } | ||
|
|
||
| function renderCurrentWeather(arr) { |
There was a problem hiding this comment.
arr is a very bad argument name.
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.
Used APi Weather data to generate current weather and five day forecast.