Put in order · Vue.js course · Module 9: Composables & VueUse
Proper Composable Initialization with API
Arrange the steps for initializing a composable that fetches data from a server:
Items to put in order
- Define refs: data, loading, error
- Return { data, loading, error, fetchData }
- Create async fetchData()
- Add onUnmounted with abort controller
- Call onMounted(() => fetchData())
You can check the correct answer by solving this task in the CodeWorlds game.