繁体   English   中英

我有这个错误 Uncaught (in promise) TypeError: Failed to fetch

[英]i have this error Uncaught (in promise) TypeError: Failed to fetch

如果我问了很多,我很抱歉,但我需要帮助。 我使用了这个脚本,它工作正常,但在控制台中我有这个错误:{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'/>

谢谢你的帮助

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM