Skip to content

EFM - API Weather App#233

Open
EugenFM wants to merge 1 commit into
projectshft:masterfrom
EugenFM:master
Open

EFM - API Weather App#233
EugenFM wants to merge 1 commit into
projectshft:masterfrom
EugenFM:master

Conversation

@EugenFM

@EugenFM EugenFM commented Mar 22, 2026

Copy link
Copy Markdown

Used APi Weather data to generate current weather and five day forecast.

Comment thread main.js
})
.then((res) => res.json())
.then((data) => addWeatherData(data));
// .then((data) => console.log(data));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not commit commented code

Comment thread main.js

// 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}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good you didn't commit your API but it should have been as an environment variable, its crashing your app.

Comment thread main.js
Comment on lines +3 to +4
let cityWeather = [];
let forecastWeather = [];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be const.

Comment thread main.js
Comment on lines +25 to +26
let lat = data[0].lat;
let lon = data[0].lon;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why let?

Comment thread main.js
Comment on lines +23 to +24
.then((res) => res.json())
.then((data) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be more clear with the argument naming.

Suggested change
.then((res) => res.json())
.then((data) => {
.then((serverData) => serverData.json())
.then((parsedData) => {

Comment thread main.js
});

// Function that grabs the coordinates to be used later by fetchWeather to generate weather data
const fetchGeoLocationData = (searchLocation) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good argument name

Comment thread main.js
};

// Convert Kelvin to Fahrenheit
const convertKelvinToFahrenheit = (kelvin) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong argument and function name. Be more precise.

Suggested change
const convertKelvinToFahrenheit = (kelvin) => {
const convertTemperatureFromKelvinToFahrenheit = (kelvinTemperature) => {

Comment thread main.js
Comment on lines +66 to +69
temp: convertKelvinToFahrenheit(data.main.temp),
name: data.name,
condition: data.weather[0].main,
icon: data.weather[0].icon,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread main.js
renderCurrentWeather(cityWeather);
}

function renderCurrentWeather(arr) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arr is a very bad argument name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants