pilotwings/frontend/views/Containers.vue

44 lines
989 B
Vue
Raw Normal View History

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