and the rest
This commit is contained in:
+5
-2
@@ -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,
|
||||
|
||||
@@ -24,7 +24,7 @@ class ErrorBoundary extends Component<Props, State> {
|
||||
|
||||
public render() {
|
||||
if (this.state.hasError) {
|
||||
return <h1>Sorry.. there was an error</h1>;
|
||||
return <h1>Sorry.. there was an error, please refresh the page</h1>;
|
||||
}
|
||||
|
||||
return this.props.children;
|
||||
|
||||
Reference in New Issue
Block a user