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
34 changes: 34 additions & 0 deletions 07week/brew.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
body,
#result {
padding: 50px;
}

h2 {
margin: 15px 401px -100px;
padding: 12px
}

ol li {
padding-bottom: 5px;
}



input[type="text"] {
width: 350px;
margin: 150px 200px;
padding: 12px;
border: 1px solid #ccc;
border-radius: 4px;
resize: vertical;
}

button {
background-color: #4caf50;
color: white;
margin: -186px ;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}
17 changes: 17 additions & 0 deletions 07week/brew.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="brew.css">
<head>
<body>
<h2>Beer choice!</h2>
<div>
<input type="text" onchange="keyup(this.value)" placeholder="Enter name ex. Buzz" />
<button onclick="getBrew()">Fetch Brewery</button>
</div>
<div id="demo"></div>
<script src="./brew.js"></script>
</body>
39 changes: 39 additions & 0 deletions 07week/brew.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
var getSearchText;

function keyup(searchText) {
//setting your input text to the global Javascript Variable for every key press
console.log(searchText)
return getSearchText = searchText;

//listens for you to press the ENTER key, at which point your web address will change to the one you have input in the search box
// if (e.keyCode == 13) {
// window.location = "http://www.myurl.com/search/" + inputTextValue;
// }
}


function getBrew() {
// const proxy = "https://cors-anywhere.herokuapp.com/";
// const enterTxt =
const api = `http://api.punkapi.com/v2/beers?beer_name=${getSearchText}`
fetch(api)
.then(function(response) {
return response.json()
console.log(response)
})
.then(function(result) {
console.log('result', result)
let output =
`<h2> </h2>`
result.forEach((function(brew){
output += `
<ul>
<li>${brew.name} id: ${brew.id}</li>
<li>${brew.description}, ${brew.ebc}</li>
<li>Boil Volume: ${brew.boil_volume.value}</li>
</ul>
`
}))
document.getElementById("demo").innerHTML = output;
})
}