After implementing the following function to retrieve images from my API, I encountered an issue:
function getImages() {
console.log("Ignite");
fetch('https://api.itseternal.net/eternal/stats', {
headers: {
"Access-Control-Allow-Origin": "https://itseternal.net"
},
mode: "cors",
})
.then((result) => result.json())
.then((api) => {
document.getElementById('cover').src = api.song.covers.big;
var bgString = `background-image: url(` + api.song.covers.big + `);`;
document.getElementById('body').style = bgString;
})
.catch(() => {
document.getElementById('cover').src = "https://callmehspear.com/cdn/e_black_branding.png";
document.getElementById('body').style = "background-image: url(https://callmehspear.com/cdn/e_black_branding.png);";
});
}
Although it initially worked, running the function now results in excessive requests being sent to the API, causing the server to receive an overwhelming amount of traffic.