From c777ef74e103a2cf0184066ec436218c9f0e245d Mon Sep 17 00:00:00 2001 From: dadobos Date: Sat, 3 Jun 2023 19:52:31 +0200 Subject: [PATCH] and the rest --- src/API.ts | 7 +++++-- src/components/ErrorBoundary.tsx | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/API.ts b/src/API.ts index f0ff859..6f3a633 100644 --- a/src/API.ts +++ b/src/API.ts @@ -7,8 +7,11 @@ export const fetchQuizQuestions = async ( difficulty: string ) => { try { - let anyCategory: string = category === 1 ? '' : '&category=' + category; - const endpoint = `https://opentdb.com/api.php?amount=${amount}${anyCategory}&difficulty=${difficulty}&type=multiple`; + + const endpoint = `https://opentdb.com/api.php?amount=${amount}${category === 1 ? '' : '&category=' + + category}&difficulty=${difficulty}&type=multiple`; + + const data = await (await fetch(endpoint)).json(); return data.results.map((question: QuestionType) => ({ ...question, diff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx index 6037985..d360481 100644 --- a/src/components/ErrorBoundary.tsx +++ b/src/components/ErrorBoundary.tsx @@ -24,7 +24,7 @@ class ErrorBoundary extends Component { public render() { if (this.state.hasError) { - return

Sorry.. there was an error

; + return

Sorry.. there was an error, please refresh the page

; } return this.props.children;