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

Add cat api #457

Closed
wants to merge 1 commit into from
Closed
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
40 changes: 40 additions & 0 deletions New_APIs/Cat API/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
width: 300px;
height: 300px;
background: url('Cat.jpg') no-repeat center center;
background-size: cover;
display: flex;
justify-content: center;
align-items: center;
}
.container {
padding: 8px;
border-radius: 0.5rem;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.Dog {
display: inline-flex;
margin: auto 10px;
font-size: 1.125rem;
color: #cc8c2b; /* blue-500 */
border-radius: 0.5rem;
border: 1px solid rgb(236, 229, 128);
padding: 10px;
background-color: white;
}
</style>
<title>Random Cat</title>
</head>
<body>
<div class="container">
<p id="DogElement" class="Dog">Loading...</p>
</div>
<script src="script.js"></script>
</body>
</html>
12 changes: 12 additions & 0 deletions New_APIs/Cat API/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "Cat facts",
"version": "0.0.1",
"manifest_version": 2,
"browser_action": {
"default_popup": "index.html",
"default_icon": "Cat.png"
},
"icons": {
"128": "Cat.png"
}
}
10 changes: 10 additions & 0 deletions New_APIs/Cat API/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
document.addEventListener('DOMContentLoaded', () => {
fetch('https://catapi./api/v2/facts')
.then(response => response.json())
.then(DogData => {
const DogText = DogData.data[0].attributes.body;
const DogElement = document.getElementById('DogElement');
DogElement.innerHTML = DogText;
})
.catch(error => console.error('Error fetching the Dog:', error));
});
Loading