Created
March 9, 2019 08:02
-
-
Save yhaskell/1ff5088e7f862b077fd065225c234e81 to your computer and use it in GitHub Desktop.
weather in London
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Weather in London</title> | |
</head> | |
<body> | |
<p>Current weather in London:</p> | |
<script> | |
const token = 'xxxxx'; | |
const id = 2643743; | |
fetch(`http://api.openweathermap.org/data/2.5/weather?id=${id}&units=metric&APPID=${token}`) | |
.then(data => data.json()) | |
.then((data) => { | |
const div = document.createElement('div'); | |
div.innerHTML = `${data.weather.map(w => w.description).join(', ')}, ${data.main.temp.toFixed(0)}ºC`; | |
document.body.appendChild(div); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment