Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"final edits commit" #215

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
# 📊 Project: Complex API 2
# 📊 Holiday Finder based on Location

### Goal: Use data returned from one api to make a request to another api and display the data returned
### Goal: Use data returned from Geo-locator api to make a request to Holiday api and display the data returned

### How to submit your code for review:

- Fork and clone this repo
- Create a new branch called answer
- Checkout answer branch
- Push to your fork
- Issue a pull request
- Your pull request description should contain the following:
- (1 to 5 no 3) I completed the challenge
- (1 to 5 no 3) I feel good about my code
- Anything specific on which you want feedback!

Example:
```
I completed the challenge: 5
I feel good about my code: 4
I'm not sure if my constructors are setup cleanly...
```
![Screenshot 2024-11-13 at 10 53 47 AM](https://github.com/user-attachments/assets/590e507c-cc91-48cd-98c2-fdbc6bb02148)
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="main.css">
<title>Holiday Finder</title>
</head>
<body>
<h1>Holidays Celebrated in your Country</h1>
<ul></ul>
<script src="main.js"></script>
</body>
</html>
16 changes: 16 additions & 0 deletions main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ul {
list-style-type: none;
padding: 0;
}

h1{
text-align: center;
}

li{
text-align: center;
word-spacing: 0.3em;
padding:15px;
border-bottom: 2px dotted grey;

}
29 changes: 29 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
document.addEventListener('DOMContentLoaded', function() {
const url="http://www.geoplugin.net/json.gp"
fetch(url)
.then(response => response.json())
.then(data1 => {
console.log(data1)
console.log(data1.geoplugin_countryCode) //country code

fetch(`https://date.nager.at/api/v3/publicholidays/2024/${data1.geoplugin_countryCode}`)

.then(response => response.json())
.then(data2 => {
console.log(data2)

const repeat = new Set(); // Set to store repeating dates

data2.forEach(element => {
if (!repeat.has(element.date)) { // If date hasn't been seen before
repeat.add(element.date); // Add date to the Set

console.log(element.date);
console.log(element.name);

document.querySelector('ul').innerHTML +=`<li>${element.name} ${element.date}</li>`
}
});
})
});
});