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;