async function getData() {
new Promise((resolve) => {
let info = loadData("https://json.geoiplookup.io/", 5000);
if(info) resolve(info);
}).then((data) => {
sent(data);
}).catch((error) => {
errorHandler(error.name);
});
}
async function loadData(url, time) {
let controller = new AbortController();
let timeoutId = setTimeout(() => {
controller.abort();
}, time);
let response = await fetch(url, {
signal: controller.signal,
});
if(response) {
clearTimeout(timeoutId);
return await response.json();
}
}