Skip to content

Commit

Permalink
correct typo in html and get api fetch working
Browse files Browse the repository at this point in the history
  • Loading branch information
kenyansa committed Jul 11, 2023
1 parent aaa8f34 commit 7d0579a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Daily Motivational Quotes</title>
<link rel="stylesheet" href="styles.css">

</head>
<body>
<div class="quote-card">
Expand Down
6 changes: 6 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const api_url = "https://api.api-ninjas.com/v1/quotes?category=health"
const apiKey = 'soP2DeFDH0h3N+n7RWfAiA==7bCg5koQKLpC0Av5'
const quoteElement = document.getElementById("quote");
const authorElement = document.getElementById("author");

async function getQuote(url){
const res = await fetch(url, {
Expand All @@ -9,5 +11,9 @@ async function getQuote(url){
});
const data = await res.json();
console.log(data);
//set innerHTML of the quote element
quoteElement.innerHTML = data[0].quote
// Set theinnerHTML of the author element
authorElement.innerHTML = data[0].author;
}
getQuote(api_url)

0 comments on commit 7d0579a

Please sign in to comment.