}, QUEUE_WAIT_TIME);
}
- // Function to make a request to the RuneScape wiki API with caching and throttling
+ // Function to make a request to the RuneScape wiki API with caching, throttling, Discord tag in GET, and optional headers
async function requestBucket(query, oldschool = false) {
const url = new URL(`https://${oldschool ? "oldschool." : ""}runescape.wiki/api.php`);
+
+ // Add your Discord tag as a GET parameter
const params = {
action: 'bucket',
format: 'json',
query: query,
- origin: '*' // Required for CORS
+ origin: window.location.origin, // Required for CORS
+ user: 'unlishema#5238' // Discord tag in GET
};
url.search = new URLSearchParams(params).toString();
return enqueueRequest(async () => {
console.log(`Fetching fresh data: ${url}`);
- const response = await fetch(url);
+ const response = await fetch(url, {
+ headers: {
+ 'X-Discord-User': 'unlishema#5238', // Optional metadata header
+ 'X-Website': window.location.origin, // Optional site header
+ 'X-Environment': 'production' // Optional environment header
+ }
+ });
+
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
}, QUEUE_WAIT_TIME);
}
- // Function to make a request to the RuneScape wiki API with caching and throttling
+ // Function to make a request to the RuneScape wiki API with caching, throttling, Discord tag in GET, and optional headers
async function requestBucket(query, oldschool = false) {
const url = new URL(`https://${oldschool ? "oldschool." : ""}runescape.wiki/api.php`);
+
+ // Add your Discord tag as a GET parameter
const params = {
action: 'bucket',
format: 'json',
query: query,
- origin: '*' // Required for CORS
+ origin: window.location.origin, // Required for CORS
+ user: 'unlishema#5238' // Discord tag in GET
};
url.search = new URLSearchParams(params).toString();
return enqueueRequest(async () => {
console.log(`Fetching fresh data: ${url}`);
- const response = await fetch(url);
+ const response = await fetch(url, {
+ headers: {
+ 'X-Discord-User': 'unlishema#5238', // Optional metadata header
+ 'X-Website': window.location.origin, // Optional site header
+ 'X-Environment': 'production' // Optional environment header
+ }
+ });
+
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}