Me ajudem por favor, to quebrando a cabeça aqui e nao to encontrando o erro https://github.com/Jvsvic/screenmatch-frases index.js
import getDados from "./getDados.js";
const btnSortear = document.querySelector('.btn-sortear');
const fichaDescricao = document.getElementById('ficha-descricao');
function carregarInfoSerie() {
getDados(`/series/frases`)
.then(data => {
fichaDescricao.innerHTML = `
<img src="${data.poster}" alt="${data.titulo}" />
<div>
<h2>${data.titulo}</h2>
<div class="descricao-texto">
<p><i>"${data.frase}"</i></p>
<p><b>Citado por:</b> ${data.personagem}</p>
</div>
</div>
`;
})
.catch(error => {
console.error('Erro ao obter informações da série:', error);
fichaDescricao.innerHTML = `<p>Erro ao carregar informações. Tente novamente.</p>`; // Exibe mensagem de erro
});
}
window.onload = carregarInfoSerie;
btnSortear.addEventListener('click', carregarInfoSerie);
getdados.js
// URL base da API
const baseURL = 'http://localhost:5501';
export default function getDados(endpoint) {
return fetch(`${baseURL}${endpoint}`)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.catch(error => {
console.error('Erro ao acessar o endpoint', error);
throw error; // Rejeita a promessa com o erro
});
}
cmd
C:\Windows\System32>netstat -ano | findstr :5501
TCP 0.0.0.0:5501 0.0.0.0:0 LISTENING 6356
TCP 127.0.0.1:5501 127.0.0.1:61337 ESTABLISHED 6356
TCP 127.0.0.1:5501 127.0.0.1:61488 TIME_WAIT 0
TCP 127.0.0.1:5501 127.0.0.1:61489 TIME_WAIT 0
TCP 127.0.0.1:5501 127.0.0.1:61492 TIME_WAIT 0
TCP 127.0.0.1:5501 127.0.0.1:61493 ESTABLISHED 6356
TCP 127.0.0.1:5501 127.0.0.1:61502 TIME_WAIT 0
TCP 127.0.0.1:5501 127.0.0.1:61503 TIME_WAIT 0
TCP 127.0.0.1:5501 127.0.0.1:61513 ESTABLISHED 6356
TCP 127.0.0.1:61337 127.0.0.1:5501 ESTABLISHED 5776
TCP 127.0.0.1:61493 127.0.0.1:5501 ESTABLISHED 5776
TCP 127.0.0.1:61511 127.0.0.1:5501 TIME_WAIT 0
TCP 127.0.0.1:61512 127.0.0.1:5501 TIME_WAIT 0
TCP 127.0.0.1:61513 127.0.0.1:5501 ESTABLISHED 5776
C:\Windows\System32>taskkill /PID 6356 /F
ÊXITO: o processo com PID 6356 foi finalizado.
C:\Windows\System32>netstat -ano | findstr :5501
TCP 127.0.0.1:5501 127.0.0.1:61503 TIME_WAIT 0
TCP 127.0.0.1:61511 127.0.0.1:5501 TIME_WAIT 0
TCP 127.0.0.1:61512 127.0.0.1:5501 TIME_WAIT 0