fix: add types

This commit is contained in:
Rekhtina Anastasia 2025-05-18 01:14:06 +07:00
parent ca796b03f5
commit f5fb8f6a1a

View File

@ -1,9 +1,25 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue'; import { ref } from 'vue';
// Типы лучше вынести в отдельный файлик, конечно
// я их для наглядности оставил
type Application = {
name: string
}
type Action = {
id: string
place: string;
text: string
applications: Application[]
}
type Team = {
actions: Action[]
}
const place = ref("") const place = ref("")
// Здесь тип поправь если че const team = ref<Team | null>(null)
const team = ref()
function getTeam() { function getTeam() {
fetch("http://localhost:8090/team", { fetch("http://localhost:8090/team", {
@ -13,8 +29,8 @@ import { ref } from 'vue';
"X-Password": "pass" "X-Password": "pass"
}, },
}) })
.then((response) => { .then(async (response) => {
team.value = response.json() team.value = await response.json()
}) })
.then((json) => console.log(json)); .then((json) => console.log(json));
} }
@ -28,11 +44,11 @@ import { ref } from 'vue';
</script> </script>
<template> <template>
<div v-if="!team.actions.length"> <div v-if="!team">
Пора решать загадку Пора решать загадку
</div> </div>
<template v-else> <template v-else>
<div v-for="action in team.actions" :key="action"> <div v-for="action in team.actions" :key="action.id">
<p>{{ action.text }}</p> <p>{{ action.text }}</p>
</div> </div>
</template> </template>