-
Notifications
You must be signed in to change notification settings - Fork 51
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
weather app #22
base: main
Are you sure you want to change the base?
weather app #22
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done, just remember what we learned about API keys and using JSON files.
"stadium": "Old Trafford", | ||
"founded": 1878 | ||
}, | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put this in an actual .json file and import it if needed. Now it is useless.
const options = { | ||
method: 'GET', | ||
headers: { | ||
'X-RapidAPI-Key': '08b2e4a664msh162c459a452cb14p1e70a3jsnd054693f2b71', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hide the API key
@@ -0,0 +1,50 @@ | |||
|
|||
const apiKey="3975e1c2286a8c534bd280117c6b3ebe"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
|
||
|
||
|
||
async function checkweather(city){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done
const sunset = data.sys.sunset; | ||
|
||
document.querySelector(".city").innerHTML= data.name; | ||
document.querySelector(".temp").innerHTML= Math.round(data.main.temp) + "°c"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use innerText or textContent
document.querySelector(".city").innerText = data.name;
document.querySelector(".temp").innerText = Math.round(data.main.temp) + "°c";
document.querySelector(".wind").innerText = data.wind.speed + "km/h";
document.querySelector(".sunset").innerText = new Date(sunset * 1000).toString();
} ) | ||
|
||
searchbox.addEventListener("keydown", (event) => { | ||
if (event.keyCode === 13) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool keyboard shortcut
No description provided.