13 lines
459 B
TypeScript
13 lines
459 B
TypeScript
import { computed } from 'vue'
|
|
import { useApiResource } from '@/Composables/useApiResource'
|
|
import type { Flight } from '@/Types/types'
|
|
|
|
export function useFlights(url: string, departedOnly: boolean = false) {
|
|
const requestUrl = departedOnly ? `${url}/departed` : url
|
|
const { data, loading, error } = useApiResource<Flight[]>(requestUrl)
|
|
|
|
const flights = computed(() => data.value ?? [])
|
|
|
|
return { flights, flightsLoading: loading, error }
|
|
}
|