From 1b57cb90cb2f8201a1a72372a0c43422e9b06805 Mon Sep 17 00:00:00 2001
From: G174 <31766585+G174@users.noreply.github.com>
Date: Tue, 10 Oct 2017 13:24:27 +0800
Subject: [PATCH] randomQuotes
---
index.html | 16 ++++++++++++++++
script.js | 33 +++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
create mode 100644 index.html
create mode 100644 script.js
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..295fee0
--- /dev/null
+++ b/index.html
@@ -0,0 +1,16 @@
+
+
+
+
+ Random Quote Generator
+
+
+
+
+
+
+
+
+
diff --git a/script.js b/script.js
new file mode 100644
index 0000000..8242ea8
--- /dev/null
+++ b/script.js
@@ -0,0 +1,33 @@
+$(function() {
+ var ul = $('ul');
+ var myHeaders = new Headers({
+ "X-Mashape-Key": "V6MbXJDZysmsh47slacZuCcATTLap1OEWHjjsnT7mLwcOTxTAU"
+ });
+
+ var myInit = { Method: 'POST',
+ headers: myHeaders
+ };
+ var url = "https://andruxnet-random-famous-quotes.p.mashape.com/?cat=movies&count=10"
+
+ $('button').on('click', function() {
+ fetch(url, myInit)
+ .then((response) => {
+ // console.log('fetched')
+ return response.json()
+ })
+ .then(data => {
+ data.forEach(function (element) {
+ var quote = element.quote;
+ var author = element.author;
+ var $p = $('').text(`Author: ${author}`)
+ var $li = $('
').text(`Quote: ${quote}`);
+ ul.append($li, $p)
+ })
+ })
+ .catch((err) => {
+ // console.log(err)
+ })
+ })
+
+
+});