diff --git a/src/App.jsx b/src/App.jsx index b7bde75..92dfc1e 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -14,6 +14,19 @@ function App() { setSelectedAnswer(selection); }; + const nextQuestion = async() => { + try { + const response = await fetch("https://opentdb.com/api.php?amount=1&category=9&type=multiple"); + const data = await response.json(); + const newQuestion = data.results[0]; + + setQuestionData(newQuestion); // Update the question data with the new question + setSelectedAnswer(null); // Reset the selected answer + } catch (error) { + console.error("Failed to fetch a new question", error); + } + }; + let card; if (selectedAnswer) { @@ -41,7 +54,7 @@ function App() {

Trivia App

- + {card}