const baseurl = "https://beta.econuker.xyz/api"; // "https://api.econuker.xyz"
const authtoken = null; // "your auth token here"
const headers = authtoken ? {
"authorization": authtoken
} : {};
fetch(baseurl + "/servers", { headers })
.then(response => {
if (response.ok) {
return response.json();
} else {
throw new Error("Request failed with status: " + response.status);
}
})
.then(data => {
console.log(data);
})
.catch(error => {
console.error(error);
});
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
const baseurl = "https://beta.econuker.xyz/api"; // "https://api.econuker.xyz"
const authtoken = null; // "your auth token here"
const headers = authtoken ? {
"authorization": authtoken
} : {};
async function asyncFunction() {
const response = await fetch(baseurl + "/servers", { headers });
if (response.ok) {
const data = await response.json();
return data;
} else {
throw new Error("Request failed with status: " + response.status);
}
}
asyncFunction()
.then(data => {
console.log(data);
})
.catch(error => {
console.error(error);
});