0
Hello I have a json : http://mulher.store/clara/admin/api/empresa.php?e=8
this api data needs to appear in several places of my html page: example:
<div id="community-members-member-top-title" class="empresas">
<h1> Hotel Sol Y Luna</h1>
<p class="page-text9">Fundo Huincho Lote A5</p>
</div>
these two tags I was able to change... but I blocked the images...
<script>
fetch("http://mulher.store/clara/admin/api/empresa.php?e=8").then((answer) => {
answer.json().then((response) => {
console.log(response);
const empresas = document.querySelector(".empresas");
li = document.createElement("h1");
li.innerHTML = `
<p>${response.empresa.nome}</p>
`;
empresas.append(li);
const pagetext9 = document.querySelector(".page-text9");
li = document.createElement("p");
li.innerHTML = `
<p>${response.empresa.endereco}</p>
`;
pagetext9.append(li);
});
});
</script>
<script>
const baseURL = `http://mulher.store/clara/admin/api/empresa.php?e=8`;
fetch(baseURL).then((answer) => {
answer.json().then((response) => {
console.log(response);
const imagens = response.fotos.map((foto) => {
return `
<img src="https://remmote.la/img/community/${foto.url}" alt="fotos" />
`;
});
const galeria = document.querySelector(".galeria");
li = document.createElement("picture");
li.innerHTML = `
<picture>
${imagens}
</picture>
`;
galeria.append(li);
});
});
</script>
html images:
<div class="community-members-member-content-gallery-imgs-img-inner-inner">
<picture class="galeria">
<p class="galeria-fotos"></p>
<picture>
<picture>
but the image does not load
link: woman.store/clara/Tiago
I think it would be easier to fetch a single time and save to a variable, so for example
const dados = fetch('http://mulher.store/clara/admin/api/empresa.php?e=8');
and then use the "data" variable where you need it– Ricardo Pontual