Added main page and basic axios query

This commit is contained in:
Alexis
2021-03-04 21:39:23 +01:00
parent dae29530c4
commit 434fe4f6fd
12 changed files with 190 additions and 17 deletions

View File

@@ -0,0 +1,13 @@
<template>
<section class="celestial">
<h2>Single Celestial</h2>
</section>
</template>
<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
name: "Celestial"
});
</script>

View File

@@ -0,0 +1,43 @@
<template>
<section class="celestials">
<h2>Le système solaire</h2>
<div class="section-content">
<celestials-list :celestials="celestials" />
</div>
</section>
</template>
<script lang="ts">
import { defineComponent } from "vue";
import axios from "axios";
import CelestialsList from "@/components/celestials/CelestialsList.vue";
export default defineComponent({
name: "Celestials",
components: {
CelestialsList
},
data() {
return {
celestials: []
};
},
methods: {
fetchBodies() {
return axios
.get("https://api.le-systeme-solaire.net/rest/bodies/")
.then(res => {
return res.data.bodies;
})
.catch(err => {
console.log(err);
return [];
});
}
},
async mounted() {
this.celestials = await this.fetchBodies();
}
});
</script>