Skip to content
Open

dog #269

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
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,29 @@
- (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...
```

Get doggy

press button, get doggie!

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

Tech used: HTML, CSS, JavaScript

I used a simple fetch request to get doggy!

Optimizations

I would get more doggy

...

(actually, i would style it a little bit)

Lessons Learned:

I learned how to get doggy through doggie api.
Empty file added css/style.css
Empty file.
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">
<title>Document</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<button id="first">I love dogs</button>
<div></div>
<script src="js/main.js"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
document.querySelector('#first').addEventListener('click', getData)


async function getData() {
const url = "https://dog.ceo/api/breeds/image/random";
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.message}>`
} catch (error) {
console.error(error.message);
}
}