From 6e5cdb0388362924c9718e0660c753902bcc718e Mon Sep 17 00:00:00 2001 From: talksik Date: Mon, 9 May 2022 06:50:36 -0500 Subject: [PATCH] nice grabbing quote nice simple --- packages/desktop/src/pages/router/index.tsx | 27 ++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/packages/desktop/src/pages/router/index.tsx b/packages/desktop/src/pages/router/index.tsx index 07d742d..487fb86 100644 --- a/packages/desktop/src/pages/router/index.tsx +++ b/packages/desktop/src/pages/router/index.tsx @@ -96,21 +96,24 @@ export default function NirvanaRouter() { ); } -type Quote = { q: string; a: string; h?: string }; +type Quote = { + content: string; + author: string; + length: number; + dateAdded: Date; + _id: string; + tags: string[]; +}; function FlowState() { const [quote, setQuote] = useState(null); useEffect(() => { - fetch("https://zenquotes.io/api/random") - .then((res) => { - console.log(res); - - return res.json(); - }) - .then((data: any) => { + fetch("https://api.quotable.io/random") + .then((res) => res.json()) + .then((data: Quote) => { console.warn(data); - // setQuote(res[0]); + setQuote(data); }) .catch((error) => { // do nothing, don't bother user, just don't show the quote @@ -122,8 +125,10 @@ function FlowState() {
{quote && ( - {quote.q} - {quote.a} + + "{quote.content}" + + {quote.author} )}