Reputation: 33
I am sorry if I asking alot but i need help. I used this script it is worked ok but in console i have this error :{Uncaught (in promise) TypeError: Failed to fetch} can any one to tell me where is my mistake.
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'/>
thanks for any help
Upvotes: 2
Views: 2499
Reputation: 3
I think that the way you are using fetch is not correct! fetch is used for an HTTP request, so u need to specify the URL as a parameter I think.
check the link on the MDN website https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
Upvotes: 0