Skip to content

Instantly share code, notes, and snippets.

@lovemycodesnippets
Last active February 7, 2025 17:26
Show Gist options
  • Save lovemycodesnippets/1c5971cf8e32fcf913f89f112797e9e6 to your computer and use it in GitHub Desktop.
Save lovemycodesnippets/1c5971cf8e32fcf913f89f112797e9e6 to your computer and use it in GitHub Desktop.
From the article "Building a Quiz App with Nuxt and Xata"
<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