and the rest

This commit is contained in:
2023-06-03 19:52:31 +02:00
parent bd49129273
commit c777ef74e1
2 changed files with 6 additions and 3 deletions
+5 -2
View File
@@ -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,
+1 -1
View File
@@ -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;