1

I have been trying to access data from the Brawl Stars API for a while now, trying many different things. When you make API keys you have to whitelist IPs. My code uses node-fetch. I have been successful when using my home internet and IP address. I would like to be able to deploy it to Glitch.com but they use the AWS server network so I would have to whitelist an entire range of IPs. I thought I could use a proxy to route the requests so I could just whitelist a couple of different IPs as opposed to hundreds. I have tried using https-proxy-agent but that has proved unsuccessful. Right now it gives no response at all. I am kind of a newbie when it comes to Fetch requests so any help is appreciated. Here is my code:

const getJSON = async url => {
try {
    const response = await fetch(url, { agent: new HttpsProxyAgent('placeholderproxy:port') }, {
        method: 'GET',
            headers: {
                Accept: 'application/json',
                Authorization: process.env.BS_TOKEN,
            },
        });
    if(!response.ok) {throw new Error(response.statusText);}
        const data = await response.json();
        return data;
}
catch(error) {
return error;
}
CactusBoy
  • 13
  • 1
  • 6

0 Answers0