/ Fixed comp api bug
This commit is contained in:
@@ -20,8 +20,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { onMounted, ref } from '@vue/composition-api'
|
|
||||||
|
|
||||||
// API
|
// API
|
||||||
import { fetchCelestials } from '@/api/le-systeme-solaire'
|
import { fetchCelestials } from '@/api/le-systeme-solaire'
|
||||||
|
|
||||||
@@ -37,23 +35,21 @@ export default {
|
|||||||
CelestialsList,
|
CelestialsList,
|
||||||
NestLoader
|
NestLoader
|
||||||
},
|
},
|
||||||
|
|
||||||
setup () {
|
|
||||||
const celestials = ref([])
|
|
||||||
|
|
||||||
const getCelestials = async () => {
|
|
||||||
celestials.value = await fetchCelestials()
|
|
||||||
celestials.value = addCelestialsType(celestials.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(getCelestials)
|
|
||||||
|
|
||||||
return { celestials }
|
|
||||||
},
|
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
celestials: [],
|
||||||
error: ''
|
error: ''
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted () {
|
||||||
|
fetchCelestials()
|
||||||
|
.then((res) => {
|
||||||
|
this.celestials = addCelestialsType(res)
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.error = 'Impossible de récupérer les astres.'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user