首页 > 解决方案 > why axios get method request send twice?

问题描述

enter image description hereI 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);
                  })

标签: vue.js

解决方案


这是一个预检请求

这是一个 OPTIONS 请求,使用三个 HTTP 请求标头:Access-Control-Request-Method、Access-Control-Request-Headers 和 Origin 标头。

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


推荐阅读