diff options
author | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2019-11-30 13:12:30 +0100 |
---|---|---|
committer | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2019-11-30 13:12:30 +0100 |
commit | 070b7725be5fb0db486e9370bea5648c16c8bbfe (patch) | |
tree | e3633c94138c9a95d3534613c0a057f6d166f800 /pages/kronika | |
parent | 1ec27747a402b8d6e308f769f9f02c6324b633cb (diff) | |
download | puszcza-070b7725be5fb0db486e9370bea5648c16c8bbfe.tar.gz puszcza-070b7725be5fb0db486e9370bea5648c16c8bbfe.zip |
Fix posts listing
Diffstat (limited to 'pages/kronika')
-rw-r--r-- | pages/kronika/index.vue | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/pages/kronika/index.vue b/pages/kronika/index.vue index 4a89a48..d28c2ca 100644 --- a/pages/kronika/index.vue +++ b/pages/kronika/index.vue @@ -1,7 +1,7 @@ <template> <div style="padding-top: 20px"> <h2>Ostatnie wpisy</h2> - <div class="post-list"> + <div v-if="posts" class="post-list"> <chronicle-post v-for="(post, index) in posts" :key="index" @@ -23,20 +23,20 @@ export default { }, async asyncData() { return { - posts: k.getPosts() + posts: process.client ? undefined : k.getPosts() } }, mounted() { - this.getPosts() + if (process.client && this.posts === undefined) { + this.getPosts().then(posts => (this.posts = posts)) + } }, methods: { - getPosts() { - if (this.posts.length < 1) { - this.$axios - .get(`${window.location.origin}/api/posts.json`) - .then(r => (this.posts = r.data)) - } - console.log(this.posts) + async getPosts() { + const r = await this.$axios.get( + `${window.location.origin}/api/posts.json` + ) + return r.data } } } |