首页 > fetch跨域请求接口then()返回的response.body为null

fetch跨域请求接口then()返回的response.body为null

fetch跨域请求登录接口
图片1为network里的信息,显示已经返回成功。

图片2为fetch().then()里console.log(response)的结果:
response.body为null
并且response.json()解析时出错.

图片3为fetch的代码

请大神们指点迷津。


个人觉得应该先看请求的状态,而不是响应的数据


其实我也遇到这个问题,fetch API实现跨域请求好像是用 mod:no-cors,但请求到的body为null

问题已经解决了

不过对 no-corscors 不是很理解


虽然我没用过fetch,但看文档描述:

我怎么觉着,mode: 'cors'才是说跨域的,而且cors的全称就是Cross-origin resource sharing, 变成no-cors好像不是跨域了,你说呢?

文档地址:Request.mode

【热门文章】
【热门文章】