-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (30 loc) · 1.03 KB
/
Copy pathindex.js
File metadata and controls
38 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const submit = document.getElementById('button');
const weatherKey = '014de69db2b0b78116006b5a3fb13332'
const weatherURL = 'https://api.openweathermap.org/data/2.5/weather?q='
const getData = async () => {
const response = await fetch('https://api.openweathermap.org/data/2.5/weather?q=leeds&appid=014de69db2b0b78116006b5a3fb13332');
const post = await response.json()
console.log(post)
return post
// const city = 'leeds'
// const urlToFetch = `${weatherURL}${city}&appid=${weatherKey}`;
// let response;
// try {
// response = await fetch(urlToFetch);
// if (response.ok) {
// const jsonResponse = await response.json();
// console.log(jsonResponse);
// return jsonResponse
// }
// throw new Error('Request failed!');
// }
// catch(error) {
// console.log(error);
// }
}
const displayWeather = (event) => {
getData();
}
//submit.addEventListener('click', displayWeather);
submit.click(displayWeather)
//getData();