Data fetching with loading state 1 export default { 2 setup() { 3 const { data, loading, error } = toRefs( 4 reactive({ data: [], loading: true, error: null }) 5 ); 6 7 fetch(“https://example.com/api/users”) 8 .then((users) => (data.value = users)) 9 .catch((err) => (error.value = err)) 10 .finally(() => (loading.value = false)); 11 12 return { data, loading, error }; 13 }, 14 };