fetch 报错 Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.

TypeError: Failed to execute ‘fetch‘ on ‘Window‘: Request with GET/HEAD method cannot have body.

在“窗口”上执行“取”失败:GET / get方法的请求不能有正文。

GET requests can‘t have a request body, you can‘t make them have one. GET requests only retrieve data, they never send data.

An API that requires GET request with empty object as a body just doesn‘t work.

No, there isn‘t.

GET requests can‘t have a request body, you can‘t make them have one. GET requests only retrieve data, they never send data.

An API that requires GET request with empty object as a body just doesn‘t work.

Edit:

Apparently, GET requests are allowed to have a body. Most implementations will ignore it or reject the request. But even if the server that provides your API allows a body, you can‘t use it:

From the spec about XMLHttpRequest#send:

Initiates the request. The optional argument provides the request entity body. The argument is ignored if request method is GET or HEAD. Throws an "InvalidStateError" exception if the state is not OPENED or if the send() flag is set.

From the spec about the Request class in the fetch API:

If either init’s body member is present and is non-null or inputBody is non-null, and request’s method is GET or HEADthen throw a TypeError.

That means that the answer to your question is still No.

fetch 报错 Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.

时间: 2024-08-24 15:33:28

fetch 报错 Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.的相关文章

mvn install 报错Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2 错误: 找不到符号

报错信息 在Eclipse中执行mvn install时,console端显示如下报错信息: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project ERP: Compilation failure: Compilation failure: [ERROR] \test01\src\main\java\HStyl

06-Vue报错Failed to execute 'setAttribute' on 'Element': '{{count}}' is not a valid attribute name.

找了半天错误最后发现{{count}}放到了div里面<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <script src="vue.js"></script></head><body><div id=&q

IDEA报错Failed to execute goal

debug后报错:Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) 在ponm.xml中加入如下配置:<build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-pl

SpringBoot MAVEN编译报错Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:

参考了好几篇文章没搞定,直到查询错误关键字 An unknown compilation problem occurred 分别参考了以下博客: https://blog.csdn.net/fanrenxiang/article/details/80864908 https://blog.csdn.net/weixin_42167717/article/details/80377123 最后搞定的是这篇 https://my.oschina.net/u/170632/blog/857078 An

git报错failed to push some refs to &#39;[email&#160;protected]:Markprint/github.git&#39;

 这个不知名小错误用了我两天的空余时间mmp   就是这里报的错 输入 git push origin master -f 解释为: 远程分支上存在本地分支中不存在的提交,往往是多人协作开发过程中遇到的问题,可以先fetch再merge,也就是pull,把远程分支上的提交合并到本地分支之后再push.如果你确定远程分支上那些提交都不需要了,那么直接git push origin master -f,强行让本地分支覆盖远程分支 终于有了,以后还需要具体研究一下 虽然用的github,但是要推广一下

Jpa自定义查询报错(Failed to convert from type [java.lang.Object[]] to type)

Jpa自定义查询报错 问题背景 今天遇到一个奇怪的报错"Failed to convert from type [java.lang.Object[]] to type",这个报错,百度上也是很少的,恰恰是这样的问题,引起我了解决的欲望.先看看报错: org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.Object[]] to type [o

Vue.js报错Failed to resolve filter问题原因

Vue.js报错Failed to resolve filter问题原因 金刚 vue Vue.js js javascript 之前使用vue.js写分页功能时,写了一个过滤器,发现一个比较奇怪的错误. console控制台调试的时候 提示错误消息: Failed to resolve filter: HomePage console错误信息.jpg 我原来的写法: 原来的错误写法.jpg 错误原因 经过自己的摸索,后来发现竟然是代码顺序错误问题... 由于先执行的pageList,后执行的V

MyEclipse打开 HTML 报错Failed to create the part&#39;s controls

拷贝代码时有时会弹出这个错误,页面仍然可以访问,但是无法编辑很郁闷. MyEclipse默认打开编辑页面是MyEclipse visual html designer 右击html页面选择open with,点击 MyEclipse html Editer即可. MyEclipse打开 HTML 报错Failed to create the part's controls

Eclipse启动 报错[Failed to load the JNI shared library jvm.dll

准备要做java服务器,在安装开发环境时,启动Eclipse报错[Failed to load the JNI shared library jvm.dll] 研究了下,造成错误的原因是由于eclipse与jdk的不一致造成的. 我的开发环境是64位windows8 Pro,安装了64位jdk1.6,eclipse却粗物的安装了32位的版本,由于64位和32位匹配不一致,造成了以上错误的发生. 又尝试了一下,32位jdk+64位eclipse也会发生同样的问题. 好了,解决方法很简单,jdk和e