(myLat, myLong)
| 44 | //GET WEATHER |
| 45 | |
| 46 | function getWeather(myLat, myLong){ |
| 47 | let link = `${myApi.proxy}https://api.openweathermap.org/data/2.5/weather?lat=${myLat}&lon=${myLong}&appid=${myApi.key}`; |
| 48 | fetch(link) //send a network request and get the information from the server |
| 49 | .then(response => { |
| 50 | let data = response.json(); //now whatever response we get, parse it into json and store in data |
| 51 | return data; |
| 52 | }) |
| 53 | .then(data => { //then we update our weather object with the required data |
| 54 | // console.log(data); |
| 55 | weather.temperature.value = Math.floor(data.main.temp - KELVIN); |
| 56 | weather.description = data.weather[0].description; |
| 57 | weather.iconID = data.weather[0].icon; |
| 58 | weather.city = data.name; |
| 59 | weather.country = data.sys.country; |
| 60 | weather.humidity = data.main.humidity; |
| 61 | }) |
| 62 | .then(() => { //then display the weather to the ui |
| 63 | displayWeather(); |
| 64 | }); |
| 65 | } |
| 66 | |
| 67 | //DISPLAYING THE WEATHER TO THE UI |
| 68 | function displayWeather() { |
no test coverage detected