Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

153
Visualizações
Dynmamically Created Images With JavaScript Not Propery Loading

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.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda