Skip to content

Instantly share code, notes, and snippets.

@fredriccliver
Created September 29, 2021 07:43
Show Gist options
  • Save fredriccliver/01d7ec633a5a87bc1f53b4d10130923b to your computer and use it in GitHub Desktop.
Save fredriccliver/01d7ec633a5a87bc1f53b4d10130923b to your computer and use it in GitHub Desktop.
var weatherApiKey = "YOUR API KEY"
var destinationUrl = (cityName) => {
return `http://api.openweathermap.org/data/2.5/weather?q=${cityName}&appid=${weatherApiKey}`
}
fetch(destinationUrl(city))
.then((response) => response.json())
.then((data) => {
console.log(data)
resolve(data)
})
.catch((error) => {
reject(error)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment