报错说明:
bog.js:35 [ERROR] [2018.10.24 10:58:47] 127.0.0.1 [uuid] [thread] [class] - API Error: Body not allowed for GET or HEAD requests with UUID: 49ece288-7a32-4cbe-a421-1439f8ff3f6b when calling /xxx.com/get-xxx
事件分析:
》排查bog.js line35,bog.js是无辜的啦,明显我只是输出日志的工具而已。
》排查uuid,查看GitHub issues和源代码,我也是无辜的,仅仅生成一个唯一ID。
》排查Fetch.js请求的Request Header
经过一番排查,定位于前后代码对比
// Before Modified { method: 'POST', credentials: 'same-origin', headers: { token: 'xxxx', }, body: params, } // After Modified { method: 'GET', credentials: 'same-origin', headers: { token: 'xxxx', }, body: params, }
发现后端的请求method把之前的post改成了get请求,导致fetch.js GET请求发送body的信息错误,引起上面的报错提示。
解决方案:
在公共request的function中,判断若是get请求并且body不等于空,则把参数添加到request请求url的后面即可解决。
if (/^get$/i.test(optData.method) && optData.body) { apiPath += `${apiPath.indexOf('?') === -1 ? '?' : '&'}${optData.body.toString()}`; optData.body = null; }
相关推荐
难易程度**教程请参阅以下查看应用程序中使用的API: : 创建组件ListUsers 在ListUsers将通过Fetch API从API中获取数据,其中的功能可以获取用户列表,删除用户和添加用户。 创建组件FormCreateUser来处理新添加的...
how-to-use-fetch-api:此源代码展示了如何使用fetch API
//default headers for all requests var fetchClient = new Fetch ( '<baseURL>' , headers ) ; //POST var body = { } ; fetchClient . POST ( 'p/a/t/h' , body ) . then ( ( res ) => res . json ( ) ) . ...
fetchAPI 简单介绍如何使用fetch API获取和发布数据该存储库是我在Scotch.io上的FETCH API教程的简单演示,
Fetch API的通用工具。 fetch在网络上无处不在。 fetch-friends是最小的,自动咖喱工具库来装点fetch与,否则你可能切换到了,在这个过程中混淆其他开发商另一个HTTP库的行为。 无需仅因需要超时而将fetch替换为库...
提取API 细节(-Curso Alura) 前端API的使用是必需的。 Entenda como utilizar ométodo提取了消费者的uma API。 可以使用CRUD实用程序从HTTP提取信息。 详细信息请参见HTTP获取信息。 Aprenda como funcionam...
javascript-fetch-api
React获取挂钩 React挂钩可方便地使用Fetch API。 小(556 B)。 按计算包括Flow和TypeScript类型import React from "react" ;import useFetch from "react-fetch-hook" ;const Component = ( ) => { const { is...
拿来使用WebAssembly拱目标通过WHATWG Fetch API实现的Go http.Transport接口。用法此软件包要求支持Go WASM编译目标。 简短示例: c := http. Client { Transport : & fetch. Transport {},}resp , err := c . ...
fetch-element:用于与fetch api交互并在脱机工作时排队请求的元素
New-Fetch-Api:从本地或外部api的textjson数据中获取数据
FetchApi:使用Javascript提取APi
安装$ npm install --save make-fetch-happen 目录例子const fetch = require ( 'make-fetch-happen' ) . defaults ( { cacheManager : './my-cache' // path where cache will be written (and read)} )fetch ( '...
比其他基于Fetch API的封装优势在于,它的中间件机制支持对请求和应答进行异步处理。安装:npm install fetch-http-client --save使用:import FetchHttpClient, { json } from 'fetch-http-client'; // ...
主要介绍了python使用pip安装模块出现ReadTimeoutError: HTTPSConnectionPool的解决方法,需要的朋友可以参考下
electron-main-fetch:在Electron的主要进程中使用浏览器Fetch API
c++泡泡堂游戏单机版完整源码,帮助新手学习理解c++。
@ mihanizm56 / fetch-api同构提取的解决方案好处: 提供响应的验证(基于@ hapi / joi模式验证,并且可以使用您自己的验证功能) 提供在一个接口中发出rest-api和json-rpc协议请求的功能提供查询参数序列化(布尔值...
// with deno import http from 'https://raw.githubusercontent.com/bushblade/fetch-library/master/index.js' const api = http ( 'https://jsonplaceholder.typicode.com' ) 然后用 api . get ( '/posts' ) ...
使获取发生 ... 安装 $ npm install --save make-fetch-happen 目录 fetch.defaults minipass-fetch选项 ...const fetch = require ( 'make-fetch-happen' ) . defaults ( { cacheManager : './my-cac