为什么 axios get 方法请求发送两次? [英] why axios get method request send twice?

查看:74
本文介绍了为什么 axios get 方法请求发送两次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行 axios get 方法来调用 php 脚本.但是请求发送两次如何解决这个问题呢.我的功能:-

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 标头.

It is an OPTIONS request, using three HTTP request headers: Access-Control-Request-Method, Access-Control-Request-Headers, and the Origin header.

在这里查看 - https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request

这篇关于为什么 axios get 方法请求发送两次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆