【问题标题】:i have this error Uncaught (in promise) TypeError: Failed to fetch我有这个错误 Uncaught (in promise) TypeError: Failed to fetch
【发布时间】:2021-02-10 06:38:43
【问题描述】:

如果我问了很多问题,我很抱歉,但我需要帮助。 我使用了这个脚本,它工作正常,但在控制台中我有这个错误:{Uncaught (in promise) TypeError: Failed to fetch} 谁能告诉我我的错误在哪里。

fetch('/feeds/posts/default?alt=json')
.then(response => response.json())
.then(data => {
  var authorPosts = data.feed.entry.filter(e => e.author[0].name.$t === "mark wael");
  var len=authorPosts.length;
  console.log(len);
  $(".authorPostsCount").append(len);
});
------------------
<span class='authorPostsCount'/>

感谢您的帮助

【问题讨论】:

标签: javascript fetch blogger


【解决方案1】:

我认为您使用 fetch 的方式不正确! fetch 用于 HTTP 请求,所以我认为您需要将 URL 指定为参数。

查看MDN网站上的链接https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch

【讨论】:

  • 但它工作正常,我得到了有效的回复。但同时也会出现此错误。
猜你喜欢
  • 2018-04-03
  • 2020-07-10
  • 2017-08-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-19
  • 1970-01-01
  • 2023-01-28
相关资源
最近更新 更多