Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emily - HW 04 #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Emily - HW 04 #3

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Nov 19, 2019

No description provided.

})


function getWeatherByCity (city) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@kcycle nice work using the standard promise syntax here.



function getWeatherByCity (city) {
axios.get(`http://api.openweathermap.org/data/2.5/weather?q=${city}&APPID=1c739a9713a0919a3024a089c3b027df`)
Copy link
Contributor

Choose a reason for hiding this comment

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

@kcycle it's recommended that you use https instead of http whenever available. The use of http here may subject you to a CORS error.

@@ -8,10 +8,30 @@

<body>

<header>
Copy link
Contributor

Choose a reason for hiding this comment

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

@kcycle nice updates to the UI

axios.get(`http://api.openweathermap.org/data/2.5/weather?q=${city}&APPID=1c739a9713a0919a3024a089c3b027df`)
.then((response) => {
console.log(response.data)
displayCityName(response.data.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

@kcycle nice! I like the use of separate functions to display each element. Putting all the display logic into one function would have also adhered to the SRP rule as well.

return parseInt((kelvinUnits-273.15)*(9/5)+32)
}

function setTempFontColor (temperature) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@kcycle great job breaking out this logic into a separate function.

the only suggestion here would be to use if..elseif..esle logic instead of two separate if statements. Take a look at the approach used in the solution: https://github.com/jsd20191008/weather-api-app-solution/blob/master/js/main-promises.js#L82

$('#max-temp').html('')
}


Copy link
Contributor

Choose a reason for hiding this comment

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

@kcycle be careful regarding unnecessary blank lines...will not result in an error, but it makes the code harder to scan.

`<h4>Today's High:</h4> <p>${temperature} F°</p>`)
}

function convertToFahrenheit (kelvinUnits) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@kcycle nice job creating a separate function to convert from Celcius to Fahrenheit. However, OpenWeatherMap's API does this work for you by passing an additional request parameter with the API call: units: 'imperial' - will return the temperature in Fahrenheit

See the docs here: https://openweathermap.org/current#data

And here's how I use it in the solution: https://github.com/jsd20191008/weather-api-app-solution/blob/master/js/main-promises.js#L56

@kareemgrant
Copy link
Contributor

kareemgrant commented Dec 3, 2019

@kcycle great work! Take a look at the solution if you're interested in one way of approaching the bonus requirement (re: support for zip codes) https://github.com/jsd20191008/weather-api-app-solution/blob/master/js/main-promises.js#L48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants