Skip to content

Commit 63e0519

Browse files
committed
api-changed
1 parent 036885f commit 63e0519

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/pages/activities/RandomQuote.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ export const RandomQuote = () => {
1010
setQuote(null);
1111
setError(null);
1212

13-
const url = "https://zenquotes.io/api/random";
13+
const url = "https://stoic-quotes.com/api/quote";
1414
const proxyUrl = `https://api.allorigins.win/get?url=${encodeURIComponent(
15-
`${url}?t=${Date.now()}`
15+
url + `?t=${Date.now()}`
1616
)}`;
1717

1818
axios
1919
.get(proxyUrl)
2020
.then((res) => {
21+
// Parse the contents returned by the proxy
2122
const data = JSON.parse(res.data.contents);
22-
const q = data[0];
23-
setQuote({ q: q.q, a: q.a });
23+
setQuote({ q: data.text, a: data.author });
2424
})
2525
.catch((err) => {
2626
setError(err);
@@ -45,9 +45,7 @@ export const RandomQuote = () => {
4545
</div>
4646
)}
4747

48-
{error && (
49-
<div className="rquote-content error">{error.message}</div>
50-
)}
48+
{error && <div className="rquote-content error">{error.message}</div>}
5149

5250
{!quote && !error && (
5351
<div className="spinner-wrapper">

0 commit comments

Comments
 (0)