Characters
Create a character
Voidi
It’s the ice cream guy.
Elongated Musk
Solar panel salesman, underground tunnel digger, flamethrower marketer.
// Function to fetch JSON data from the API
async function fetchData() {
try {
const response = await fetch(‘https://corsproxy.io/?https://django–tinytmpsxei3.repl.co/get-characters/get-data’);
const data = await response.json();
return data;
} catch (error) {
console.error(‘Error fetching data:’, error);
}
}
// Function to create and append cards to the container
function createCards(data) {
const cardsContainer = document.getElementById(‘cardsContainer’);
data.forEach(person => {
const card = document.createElement(‘div’);
card.className = ‘bg-gray-800 p-6 w-full sm:w-1/2 md:w-1/4 lg:w-1/4 xl:w-1/4 rounded-xl shadow-lg flex items-center justify-start’;
card.innerHTML = `
${person.name}
${person.description}
`;
cardsContainer.appendChild(card);
});
}
// Fetch data and create cards when the page loads
window.onload = async function () {
const data = await fetchData();
if (data) {
createCards(data);
}
};