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,