-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Static Sites With Nuxt - 06 - Data From WordPress #2
- Loading branch information
Ivan Doric
committed
May 3, 2019
1 parent
e4a1ffc
commit 38927aa
Showing
3 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<template> | ||
<div> | ||
<div class="container"> | ||
<div class="post"> | ||
<h2 class="mb-8">{{ post.title.rendered }}</h2> | ||
<div v-html="post.content.rendered"></div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import axios from 'axios' | ||
export default { | ||
data() { | ||
return { | ||
post: {} | ||
} | ||
}, | ||
async asyncData({params, payload}) { | ||
if(payload) { | ||
return { | ||
post: payload | ||
} | ||
} else { | ||
return axios.get('http://nuxt-wp.localhost/wp-json/wp/v2/posts/' + params.id) | ||
.then((res) => { | ||
return { | ||
post: res.data | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
</script> |
This file contains 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