Skip to content

Commit 0885938

Browse files
committed
project start and finished files
1 parent 4c68282 commit 0885938

File tree

11 files changed

+6915
-0
lines changed

11 files changed

+6915
-0
lines changed

Diff for: promisesFun/finished/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
.cache

Diff for: promisesFun/finished/index.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=1, initial-scale=1.0">
7+
<link rel="stylesheet" href="styles.css">
8+
<title>Promieses</title>
9+
</head>
10+
11+
<body>
12+
<h1>Poke Stats</h1>
13+
<ul class="pokestats"></ul>
14+
<script src="scripts.js"></script>
15+
</body>
16+
17+
</html>

Diff for: promisesFun/finished/package.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "promises",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"dev": "parcel index.html",
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"author": "",
11+
"license": "ISC"
12+
}

Diff for: promisesFun/finished/scripts.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//fetch data from https://pokeapi.co/
2+
const listPokeStats = document.querySelector('.pokestats');
3+
fetch('https://pokeapi.co/api/v2/pokemon/ditto')
4+
.then(response => response.json())
5+
.then(data => {
6+
console.log(data)
7+
listPokeStats.innerHTML = data.stats.map(pokestat => `<li>${pokestat.stat.name}: ${pokestat.base_stat}</li>`).join("") //using .join() becuase when we take an array and toString it. It'll join it with commas
8+
})
9+
.catch(error => console.log(error));
10+
11+
12+
// Async Await
13+
// function austinIsCool() {
14+
// return new Promise(resolve => {
15+
// setTimeout(() => {
16+
// resolve('I\'m way too cool');
17+
// }, 2000);
18+
// });
19+
// }
20+
21+
// async function importantMessage() {
22+
// const myMessage = await austinIsCool();
23+
// console.log('Message from Austin', myMessage);
24+
// }
25+
26+
// importantMessage();
27+
28+
29+
//TODO:
30+
/*
31+
1.) Refactor the fetch call to use async await
32+
2.) Buil a better UI to present the data
33+
3.) Create a form that calls the api after a user submits a pokemon name
34+
4.) Display the pokemon in an image
35+
5.) Find an alternative to innerHTML
36+
37+
Major Bonus
38+
1.) Add to the collection on the page everytime a user makes a call
39+
2.) Create a delete button that can delete a pokemon from the UI
40+
3.) Create a Clear Button
41+
42+
*/

Diff for: promisesFun/finished/styles.css

Whitespace-only changes.

Diff for: promisesFun/start/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
.cache

Diff for: promisesFun/start/index.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=1, initial-scale=1.0">
7+
<link rel="stylesheet" href="styles.css">
8+
<title>Promieses</title>
9+
</head>
10+
11+
<body>
12+
<ul>
13+
<li></li>
14+
</ul>
15+
<script src="scripts.js"></script>
16+
</body>
17+
18+
</html>

0 commit comments

Comments
 (0)