pilotwings/frontend/views/Containers.vue
2024-11-03 19:14:47 +01:00

44 lines
989 B
Vue

<template>
<Loading class="container" :loading="loading">
<Message v-if="error" type="danger">{{ error }}</Message>
<ul v-if="!loading && !error">
<li v-for="container in containers" :key="container">
{{ container }}
</li>
</ul>
</Loading>
</template>
<script lang="ts">
import axios, { AxiosError } from 'axios'
import Loading from '@/components/Loading.vue'
import Message from '@/components/Message.vue'
export default {
name: 'Containers',
components: {
Loading,
Message,
},
data() {
return {
containers: [] as string[],
error: '',
loading: true,
}
},
async mounted() {
try {
const response = await axios.get<string[]>('/api/containers')
this.containers = response.data
} catch (error) {
console.error(error)
this.error =
error instanceof AxiosError ? error.message : 'Error loading containers'
} finally {
this.loading = false
}
},
}
</script>