无法在nuxtJS插件页面中使用axios发送get xhr请求

时间:2020-09-12 12:20:39

标签: laravel vue.js axios nuxt.js

我正在尝试基于该插件获得特定产品,但是当我尝试向我的由Laravel支持的API发送Ajax请求时,则无法正常工作。

我将代码粘贴到这里。

this.$axios.$get(this.$axios.defaults.baseURL + '/api/products/' + this.$route.params.slug)
    .then(response => console.log(response))
    .catch(error => console.log(error));

我可以使用Postman之类的工具来获取数据,它也可以在index.vue之类的页面上工作,但是当涉及到_slug.vue时,我发现它没有将GET HTTP方法发送到服务器。

我将发布两个屏幕截图,第一个是从_slug.vue页发送的,另一个是从index.vue页发送的,以便您可以看到标头中的区别。

enter image description here

enter image description here

0 个答案:

没有答案