Files
2026-06-21 12:52:30 +10:00

22 lines
599 B
TypeScript

// useFlights.ts
import {onMounted, ref} from "vue";
import {Flight} from "@/Types/types";
import axios from "axios";
export function useFlights(url: string, departedOnly: boolean = false) {
const flights = ref<Flight[]>([])
const flightsLoading = ref(true)
onMounted(async () => {
try {
const requestUrl = departedOnly ? `${url}/departed` : url
const response = await axios.get(requestUrl)
flights.value = response.data
} finally {
flightsLoading.value = false
}
})
return { flights, flightsLoading }
}