Skip to content
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: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,24 @@
- 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...
```

https://justinjoshi.github.io/simple-api-bootcamp/

cat

press button, get cat.


Tech used: HTML, CSS, JavaScript

I used a simple fetch request to get cat

Optimizations

shoulda put more cat tbh

Lessons Learned:
i learned that i love putting cats into the dom. its very fun to watch them be silly
Empty file added css/style.css
Empty file.
15 changes: 15 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<button id="first">I love cats</button>
<button id="second">Super cat</button>
<div></div>
<script src="js/main.js"></script>
</body>
</html>
35 changes: 35 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
document.querySelector('#first').addEventListener('click', getData)
document.querySelector('#second').addEventListener('click', getData1)

async function getData() {
const url = "https://api.thecatapi.com/v1/images/search";
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}

const result = await response.json();
document.querySelector('div').innerHTML += `<img src=${result[0].url}>`
} catch (error) {
console.error(error.message);
}
}

async function getData1(e) {
const url = "https://api.thecatapi.com/v1/images/search?limit=10";
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}

const result = await response.json();
result.forEach((x, i) => {
document.querySelector('div').innerHTML += `<img src=${result[i].url}>`
console.log('hi')
})
} catch (error) {
console.error(error.message);
}
}