This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
data () { | |
return { | |
posts: [] | |
} | |
}, | |
watch: { | |
'$fetchState.error' (error) { | |
// do something with error | |
console.log(error) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<div v-if="$fetchState.pending"> | |
<content-placeholders> | |
<content-placeholders-heading/> | |
<content-placeholders-text :lines="3" /> | |
</content-placeholders> | |
</div> | |
<div v-if="$fetchState.error"> | |
<h1>{{ $fetchState.error.statusCode }} An error occurred: {{ $fetchState.error.message }}</h1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
data () { | |
return { | |
posts: [] | |
} | |
}, | |
activated() { | |
// Call fetch again if last fetch more than 30 sec ago | |
if (this.$fetchState.timestamp <= (Date.now() - 30000)) { | |
this.$fetch() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="container"> | |
<nuxt keep-alive /> | |
</div> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
/* | |
** Plugins to load before mounting the App | |
*/ | |
plugins: [ | |
'@/plugins/vue-content-placeholders.js' | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue' | |
import VueContentPlaceholders from 'vue-content-placeholders' | |
Vue.use(VueContentPlaceholders) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<div v-if="$fetchState.pending"> | |
<content-placeholders> | |
<content-placeholders-heading/> | |
<content-placeholders-text :lines="3" /> | |
</content-placeholders> | |
</div> | |
<div v-if="post"> | |
<h1>{{ post.title }}</h1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div v-if="post"> | |
<h1>{{ post.title }}</h1> | |
<div>{{ post.body }}</div> | |
<nuxt-link to="/fetch-blog">back to list</nuxt-link> | |
</div> | |
</template> | |
<script> | |
export default { | |
data () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<h1> Blog posts </h1> | |
<div v-if="posts && posts.length"> | |
<div | |
v-for="post in posts" | |
:key="post.id"> | |
<nuxt-link :to="`/fetch-blog/${post.id}`">{{ post.title }}</nuxt-link> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div data-server-rendered="true" id="__nuxt"><!----><!----><div id="__layout"><div class="container"><div data-fetch-key="0"><h1> fetch method </h1> <p> Just check HTML source or inspect window.__NUXT__ </p></div></div></div></div><script>window.__NUXT__={layout:"default",data:[{}],fetch:[{title:"fetch method"}],error:null,state:{},serverRendered:true,routePath:"\u002Ffetch-basic",logs:[]};</script> |