提取API会显示"TypeError:提取失败".

编程入门 行业动态 更新时间:2024-10-11 13:20:13
本文介绍了提取API会显示"TypeError:提取失败".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在Chrome上,并且看到了这个奇怪的错误:

I am on Chrome, and I see this bizarre error:

TypeError: failed to fetch

(是,这是整个错误消息).

以下是生成错误的代码:

Here is the code that generated the error:

fetch(logoUrl, { method: 'put', headers: { 'Content-Type': 'image/jpeg', //encode credentials as base64 'Authorization': 'Basic ' + btoa('cdt-deployer:xyz'), }, body: imgFile // the file }).catch(function(err){ // the error appears here })

我该怎么办?我不知道怎么了我只是想将二进制图像文件发送到另一台服务器(我看不到服务器日志).

what am I supposed to do? I have no idea what's wrong. I am simply trying to send a binary image file to another server (I cannot see the server logs).

推荐答案

来自获取API文档:

遇到网络错误时, fetch()承诺会拒绝,并带有 TypeError ,尽管这通常意味着权限问题或类似问题.

A fetch() promise rejects with a TypeError when a network error is encountered, although this usually means a permissions issue or similar.

以下之一可能是网络错误"的原因:

One of these may be possible causes of "network error":

  • DNS问题
  • 位于 logoUrl 的服务器不可用/错误
  • 错误的HTTP标头导致服务器忽略请求
  • 浏览器中止-最有可能是由于在提取完成之前导航到了另一个页面

更多推荐

提取API会显示"TypeError:提取失败".

本文发布于:2023-11-24 19:44:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1626566.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:API   quot   TypeError

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!