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
21 changes: 21 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>

<h1>Random Quote</h1>
<h2>New quote</h2>
<ul>

</ul>

<script
src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="script.js" charset="utf-8"></script>


</body>
</html>
40 changes: 40 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
$(function () {
var url = 'https://andruxnet-random-famous-quotes.p.mashape.com/'

// var apiCall = fetch(url, {method:'post'}, {header: xhr.setRequestHeader("X-Mashape-Key", "YOURKEY")})

var headerKey = new Headers()
headerKey.append('X-Mashape-Key', 'jf3BSb5fISmshQPCGNR928NR0cKqp1T8hJXjsnzqXznBkpIqIL')

var init = {method: 'POST',
headers: headerKey}

// console.log('api call')
// console.log(apiCall)

var apiCall = fetch(url, init)

apiCall
.then((response) => { // when we get a response back
// console.log('response received')
// console.log(response.json())

return response.json()
})

// .then((data)
.then(data => {
console.log('data processed and converted into json')
console.log(data)

var $title = $('h1')

$title.text(data.quote)
})

.catch((err) => {
console.loh(err)
})
})

// function writeLiEveryArticle (data) {