Files
FlightsAPI/resources/js/Composables/useFlights.ts
T
2026-05-16 23:48:18 +10:00

23 lines
607 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 response = await axios.get(url, {
params: departedOnly ? { departed_only: true } : {}
})
flights.value = response.data
} finally {
flightsLoading.value = false
}
})
return { flights, flightsLoading }
}