我在路由器模块中使用Nuxt 目前,我写这样的api:
<template>
<div class="row flex">
{{posts.id}}
</div>
</template>
<script>
import axios from 'axios'
import Item from '~/components/feeds/Post.vue'
export default {
async asyncData ({ store, route }) {
let { data } = await axios.get('http://localhost:8000/api/v1/feeds/' + route.params.id + '/')
return {
posts: data
}
},
components: {
'post-detail': Item
}
}
</script>
我收到此错误: HTTP headers 我该如何解决这个问题。
答案 0 :(得分:0)
也许它可以以某种方式帮助你。
export default {
layout: 'main',
async asyncData ({store, params}) {
let projectId = params.id;
let {data} = await axios.get('https://admin.xxx.com/page/preview/' + projectId)
return {
pageContent: data.xxx,
title: data.xxx.meta_title,
description: data.xxx.meta_desc,
keywords: data.xxx.meta_key,
}
},
}