javascript - 为什么axios发送两个请求

标签 javascript reactjs http request axios

我需要 axios 方面的帮助,我不知道为什么要发送两个请求 here an image of chrome network在一个电话后

我正在使用 React,当我发送请求时,该函数仅触发一次(我调试并放置 console.logs 并获得一个响应)但在 chrome 网络中我收到两个请求,具有不同的 header 和类型。 一个有授权 token ,另一个没有 token success requestwrong request这是一个电话,我不知道发生了什么。

感谢您的宝贵时间!

最佳答案

它是 OPTION request? 吗? . OPTION 请求用于检查您的客户端是否有权向 API 发出所需的请求。

The HTTP OPTIONS method requests permitted communication options for a given URL or server. A client can specify a URL with this method, or an asterisk (*) to refer to the entire server.

关于javascript - 为什么axios发送两个请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64697829/

相关文章:

java - 无法从 Java 服务器应用程序获得响应

javascript - javascript中最简单的继承?

javascript - React Material UI - 使 slider 更新状态

css - 如何制作 svg RTL

javascript - 通过 props 传递 "this"上下文是反模式吗?

java - 从服务异常中检索 Spring Integration 中的消息

http - 是不是所有场景都可以用POST代替GET呢?

c# - 如何捕获文本区域中的回车符

javascript - AngularJS 多个 http 请求

javascript - 类型错误 : listener must be a function