Fetch data from backend before render #9175
salueii
started this conversation in
General Discussions
Replies: 1 comment 3 replies
-
<script lang="ts" setup>
import { ref, onMounted } from 'vue';
const loading = ref(true);
onMounted(async () => {
await fetch('/api/list');
loading.value = false;
});
</script> |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
May be this is simple question however I am get stick in it for many hours.
Thing is that before axios fetch data from server , component rendered and this lead to ERROR.
Fetch data code hooked in beforeCreate lifecycle method like this:
in template we use this.CmpObj like this:
I use await/async method however is not work.
any suggestion appreciated.
Beta Was this translation helpful? Give feedback.
All reactions