Skip to content

Commit

Permalink
Created function that makes a link to call the API
Browse files Browse the repository at this point in the history
  • Loading branch information
DiksonIvySon committed Oct 19, 2023
1 parent 3ebd2ab commit b8fb4e1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions weatherApp/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,16 +272,21 @@ function makeDate() {
let previousWeatherContainer = document.querySelector('.previousWeather-container');
previousWeatherContainer.textContent = "";

getPreviousData(new_dayDate);
CreatePreviousDataLink(new_dayDate);
dayDate_Day -= 1;
}

}

//function to create the API link
function CreatePreviousDataLink(new_dayDate) {
let previousDataLink = "http://api.weatherapi.com/v1/history.json?key=8badefafba8c47eb9f7184239231608&q=" + inputLocation + "&dt=" + new_dayDate;
getPreviousData(previousDataLink);
}


//function to fetch the previous data
async function getPreviousData(new_dayDate) {
let previousDataLink = "http://api.weatherapi.com/v1/history.json?key=8badefafba8c47eb9f7184239231608&q=" + inputLocation + "&dt=" + new_dayDate;
async function getPreviousData(previousDataLink) {
const response = await fetch(previousDataLink, {mode: 'cors'});
const previousDataInfo = await response.json();
displayPreviousDataInfo(previousDataInfo);
Expand Down

0 comments on commit b8fb4e1

Please sign in to comment.