import { ref } from 'vue' export const useApi = (getResult) => { const result = ref(null) const loading = ref(false) const error = ref(false) async function callAPI() { result.value = null loading.value = true error.value = false try { result.value = await getResult() } catch { error.value = true } finally { loading.value = false } } return { result, loading, error, callAPI } }