Last active
February 7, 2025 17:26
-
-
Save lovemycodesnippets/1c5971cf8e32fcf913f89f112797e9e6 to your computer and use it in GitHub Desktop.
From the article "Building a Quiz App with Nuxt and Xata"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script setup> | |
useSeoMeta({ | |
… | |
}); | |
const questionsAnswered = useState("questionsAnswered", () => 0); | |
const totalCorrect = useState("totalCorrect", () => 0); | |
const { data: questions } = await useFetch(`/api/questions`); | |
const { data: answers } = await useFetch(`/api/answers`); | |
const numQuestions = questions.value.length | |
const results = [ | |
…, | |
{ | |
min: numQuestions, | |
max: numQuestions, | |
title: "Wow, you're a genius!", | |
desc: "Studying has definitely paid off for you!", | |
}, | |
]; | |
</script> | |
<template> | |
<main> | |
<div class="ctr"> | |
<Questions | |
v-if="questionsAnswered < questions.length" | |
:questions="questions" | |
:answers="answers" /> | |
<Result v-else /> | |
<button type="button" class="reset-btn">Reset</button> | |
</div> | |
<Footer /> | |
</main> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment