I'm trying to fetch featured image from my published post but it seems impossible! I getan error :( that's the code:
function fetchSlideShow(){let endpoint = "http://loreleiheckmann.com/wordpress/wordpress/wp-json/wp/v2/Vinyls?_embed";fetch(endpoint).then(e => e.json()).then(showSlideShow);}function showSlideShow(data){console.log(data);data.forEach(showSingleSlide); showSlides();}function showSingleSlide(aSlide) {let template = document.querySelector(".slide_template").content;let clone = template.cloneNode(true);console.log(aSlide); clone.querySelector("img").setAttribute("src", aSlide._embedded["wp:featuredmedia"] [0].media_details.source_url);let SlideList = document.querySelector("#SlideList");SlideList.appendChild(clone);}
While going to the array I see error 401 :( and moreover: Cannot read property 'source_url' of undefined" I don't know what I'm doing wrong .. any insights?HERE ARE THE ERRORS -> 401 ON CONSOLE + PROBLEM WITH URL.: