Created
August 29, 2018 15:44
-
-
Save fdjones/e9d2d7ad81de22357ede53647a34d1c3 to your computer and use it in GitHub Desktop.
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
const forecast = document.querySelector(".forecast"); | |
const temperature = document.querySelector(".temperature"); | |
const btn = document.querySelector("button"); | |
async function getWeatherData() { | |
const returnData = await axios.get( | |
"api.openweathermap.org/data/2.5/weather?id={MyAPIKeyGoezHere}", | |
{ | |
headers: { | |
'Access-Control-Allow-Origin': '*', | |
"Content-Type": "application/json" | |
} | |
} | |
); | |
return returnData.data; | |
} | |
getWeatherData().then(res => console.log("data: ", res)); | |
btn.addEventListener("click", () => { | |
const result = getWeatherData().then(res => alert(JSON.stringify(res))); | |
forecast.innerHTML = JSON.stringify(result); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment