vue.js - why axios get method request send twice?
问题描述
I run the axios get method to call php script.but request send twice how to solve this problem. myfunction:-
axios.get('http://13.233.179.174/customers_log.php',{
headers: {
'Access-Control-Allow-Origin': '*'
},
})
.then(function (response) {
$("#spinner").hide();
console.log('this is response work');
console.log(response.data);
})
.catch(function (error) {
$("#spinner").hide();
console.log(error);
})
解决方案
这是一个预检请求
这是一个 OPTIONS 请求,使用三个 HTTP 请求标头:Access-Control-Request-Method、Access-Control-Request-Headers 和 Origin 标头。
在这里检查 - https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request
推荐阅读
- c++ - 在不使用虚拟继承的情况下继承接口的最佳方法是什么?
- c++ - *(iterator) 和 *(++iterator) 在下面的 c++ 代码中是什么意思?
- javascript - 减少将数组转换为唯一数组属性
- ssh - 修复 tput:使用 SSH 运行远程 shell 脚本时没有指定 $TERM 的值和没有指定 -T
- ios - 通过 TOR swift 路由 WKWebView
- python - 日期时间格式 Python 的用户输入
- php - 在另一个文件中调用函数
- android - ExoPlayer 下载后从缓存/离线播放文件
- cypress - 带有正则表达式的赛普拉斯“have.attr”
- php - 如何在 PHP 中按日期(今天、昨天、8 月 29 日、28 日等)从 SQL 中对 foreach 项目进行排序?