Skip to content

Commit

Permalink
Add author in userState & implemnet to display the author
Browse files Browse the repository at this point in the history
  • Loading branch information
HossainAraf committed Aug 28, 2023
1 parent 3e830a2 commit 6209a2e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/DisplayQuote.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import '../styles/display-quote.css';

const QuoteComponent = () => {
const [quote, setQuote] = useState(null);
const [author, setAuthor] = useState(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(false);

Expand All @@ -20,6 +21,7 @@ const QuoteComponent = () => {
const response = await fetch(apiURL, options);
const data = await response.json();
setQuote(data[0].quote);
setAuthor(data[0].author);
// console.log(data[0]);
} catch (error) {
setError(true);
Expand All @@ -39,9 +41,10 @@ const QuoteComponent = () => {
</div>
)}
{quote && (
<div id="display-joke">
<div id="display-quote">
<h4>Quote:</h4>
<p>{quote}</p>
<p id="author">{author}</p>
</div>
)}
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/styles/display-quote.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
margin-top: 1.5%;
}

#display-quote #author {
color: #463535;
}

0 comments on commit 6209a2e

Please sign in to comment.