api - vuejs2 获取返回网络错误
问题描述
我正在尝试使用 vuejs2 访问 prestashop API
<script>
import axios from 'axios'
export default {
data () {
return {
get: [],
errors: []
}
},
created () {
axios({
method: 'get',
url: 'https://myprestashopsite.com/api/categories/?ws_key=J***************Z&filter[id_parent]=5&output_format=JSON'
}).then(response => {
this.get = response.data
})
.catch(e => {
this.errors.push(e)
})
}
}
在 mozilla 的 Web 开发人员控制台中,我看到我的请求返回 200,其中包含响应中的数据。但我收到“错误:网络错误 app.js%20line%201266%20%3E%20eval:15:15”作为错误捕获。
我尝试使用另一个 API 并且它有效,所以我猜它来自 prestashop api。(prestashop 版本 1.7.3.0)
有没有办法来解决这个问题 ?
解决方案
问题似乎来自 axios。我不得不向服务器添加一条规则。
我在这个线程上找到了解决方案:
https://github.com/axios/axios/issues/853
如果我的不起作用,我没有在这个线程中尝试过其他解决方案。
推荐阅读
- android - ViewPager2.setOffscreenPageLimit() 问题
- azure - 如何使用单个应用程序访问 Azure AD 中多个租户的资源?
- javascript - Discord.js 运行后面的代码后在源头运行代码
- javascript - JS - 覆盖 localStorage 以观察变化并获取键/值
- php - 如何包含来自另一个 url 的 php 函数(在 php 中)
- spring-boot - Spring boot Keycloak也阻止了未配置的url
- kivy - 在 Kivy 屏幕中嵌入 cefpython
- c++ - 倍数长度除法算法c ++问题
- mongodb - 如何在 Meteor/MongoDB 中设计“一对多关系”
- redux - 无法编译 ./src/index.js 未找到模块:无法解析 './redux/actions'