2020-02-04 18:36:22 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
2020-02-09 11:04:29 +00:00
|
|
|
<nuxt-link to="/fetch-conditional?fetch_client=true">
|
|
|
|
Fetch on client
|
|
|
|
</nuxt-link>
|
2020-02-04 18:36:22 +00:00
|
|
|
<p v-if="$fetchState.pending">
|
|
|
|
Fetching...
|
|
|
|
</p>
|
|
|
|
<pre v-else>{{ team }}</pre>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
async fetch () {
|
|
|
|
const url = (process.server ? `http://${this.$ssrContext.req.headers.host}` : '')
|
|
|
|
|
|
|
|
this.team = await fetch(`${url}/team.json`).then(res => res.json())
|
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
team: []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
fetchOnServer () {
|
|
|
|
return !this.$route.query.fetch_client
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|