Skip to content

Commit

Permalink
fix(typecheck): data.time is possibly undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
hywax committed Dec 30, 2023
1 parent 20879eb commit 4ab1529
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions components/service/Ping.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<ServiceBase v-bind="props">
<template #description>
<template v-if="ping?.time >= 0">
{{ $t('service.ping.description') }} <span class="border-b border-dashed">{{ ping.time }} {{ $t('service.ping.units') }}</span>
<template v-if="data && data?.time >= 0">
{{ $t('service.ping.description') }} <span class="border-b border-dashed">{{ data.time }} {{ $t('service.ping.units') }}</span>
</template>
<template v-else>
{{ $t('service.ping.error') }}
Expand All @@ -16,7 +16,7 @@ import type { PingService } from '~/types/services'
const props = defineProps<PingService>()
const { data: ping, refresh } = await useFetch('/api/services/ping', { query: { id: props.id } })
const { data, refresh } = await useFetch<{ time: number }>('/api/services/ping', { query: { id: props.id } })
const { pause } = useIntervalFn(refresh, props?.options?.interval || 10000, { immediate: true })
onBeforeUnmount(pause)
Expand Down

0 comments on commit 4ab1529

Please sign in to comment.