I have a simple setup with a main Vue template like this:
<template>
<div>
[Other code here...]
<v-app style="overflow-y:hidden">
<router-view class="view"></router-view>
</v-app>
</div>
</template>
<script>
export default {
methods: {
created() {
//I NEED THIS CODE TO FINISH FIRST BEFORE ROUTER-VIEW
//TEMPLATE CREATED METHOD STARTS
await XxxService.xXXxXX()
.then((response) => {
localStorage.mySpecialVariable = yyyyy;
})
.catch(() => {
});
}
}
}
</script>
Currently, there is a race condition where the value of localStorage.mySpecialVariable
is null
when the inner template runs its create()
method. Sometimes it's there, sometimes it's not unless I run the page twice.
How can I ensure that the outer main template code completes before anything continues?