currently practicing with APIs and working on a project to do a mock up of the Pexels website. Having an issue with the creation of images, but not quite sure why these will not load.
let response = JSON.parse(request.responseText);
let photoURL = response.photos.map(function (photo) {
return photo.url;
});
console.log(photoURL);
const imagesContainer = document.querySelector('.images-container');
imagesContainer.innerHTML = ``;
photoURL.forEach(photo => {
const imageDiv = document.createElement('div');
imageDiv.classList.add('image-div');
imageDiv.innerHTML = `
<img class="created-image" src=${photo}>
`;
imagesContainer.appendChild(imageDiv);
});
photoURL is an array of all the image URLs, simply trying to run a forEach on it to attach the src and append to the imagesContainer. Everything seems to be working/appending as planned, but the images will not load. If I look in the chrome dev console, the images will even have the src attribute with links that if I copy paste, do indeed work in the browser.