2016-11-07 12:53:05 +00:00
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<p>{{ post.title }}!</p>
|
2016-12-16 17:12:38 +00:00
|
|
|
<p><nuxt-link to="/">Back home</nuxt-link></p>
|
2016-11-07 12:53:05 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
const axios = require('axios')
|
|
|
|
|
|
|
|
export default {
|
2016-11-07 13:12:59 +00:00
|
|
|
data ({ req }) {
|
2016-11-19 21:16:26 +00:00
|
|
|
// We can return a Promise instead of calling the callback
|
2016-11-07 18:21:32 +00:00
|
|
|
return axios.get('https://jsonplaceholder.typicode.com/posts/1')
|
|
|
|
.then((res) => {
|
|
|
|
return { post: res.data }
|
2016-11-07 13:12:59 +00:00
|
|
|
})
|
2016-11-19 21:16:26 +00:00
|
|
|
},
|
|
|
|
head () {
|
|
|
|
return {
|
|
|
|
title: this.post.title
|
|
|
|
}
|
2016-11-07 12:53:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2016-11-07 13:12:59 +00:00
|
|
|
<style scoped>
|
2016-11-07 12:53:05 +00:00
|
|
|
p {
|
|
|
|
font-size: 20px;
|
|
|
|
text-align: center;
|
|
|
|
padding: 100px;
|
2016-11-07 13:12:59 +00:00
|
|
|
padding-bottom: 0;
|
2016-11-07 12:53:05 +00:00
|
|
|
}
|
|
|
|
</style>
|