import { fetch } from '@tauri-apps/api/http';
document.addEventListener('DOMContentLoaded', async function() {
const serverIP = 'http://185.221.21.49:30120/players.json';
const playerCountElement = document.getElementById('player-count');
const response = await fetch(serverIP, { method: 'GET', timeout: 1000, })
console.log("response:", response)
.then(response => {
if (!response.ok) {
throw new Error(`Network response was not ok: ${response.statusText}`);
}
return response.data;
})
.then(data => {
if (data && data.players) {
playerCountElement.textContent = `Játékosok száma: ${data.players.length}`;
} else {
playerCountElement.textContent = "Játékosok száma: Nem sikerült lekérni";
}
})
.catch(error => {
console.error("Error fetching player count:", error);
playerCountElement.textContent = "Játékosok száma: Nem sikerült lekérni";
});
});
Error code:
Error code: TypeError: Failed to resolve module specifier “@tauri-apps/api/http”. Relative references must start with either “/”, “./”, or “../”.
I’ve tried everything, I’ve searched and searched for a solution but I can’t find it, please help me. I just can’t get it to work.
I’ve tried a lot of things, most of which I’ve saturated by search