(asyncData) запроса posts, получить на второй (onPostDel) posts.id?
<script>
export default {
async asyncData ({ params, $axios }) {
const posts = await $axios.$get(`/api/posts/${params.id}`)
return { posts }
},
methods: {
async onPostDel () {
const id = this.posts.id
await this.$axios.$delete(`/api/post/del/${id}`)
}
}
</script>
Const id = $roure.params.id
Обсуждают сегодня