Problem with fetching data from API?

So, I’m having a problem with using this npm package on glitch. It doesn’t seem to be fetching the data from the API? Not really sure. I’ve tried so many different things to get this working. The frustrating thing is that this exact package/code runs perfectly on my local machine. Does Glitch allow fetching data from an API? I’ve been stuck on this for a good while.

My error:
SyntaxError: Unexpected token Y in JSON at position 0 at JSON.parse (<anonymous>) at module.exports (/rbd/pnpm-volume/eedb8dbd-5572-4b54-b9a9-37f61d7f583c/node_modules/ at process._tickCallback (internal/process/next_tick.js:68:7)

The code at index.js:30:27 of the skiplagged-api-wrapper:
const flightData = JSON.parse(await get({ host, path: flightUrl }));

Glitch Project

Hi @bryceremick, welcome to the Glitch forum!

There shouldn’t be any reason you would have difficulty retrieving data from an external API, so I’m not sure what the difference is, but when I load in my browser I get what seems to be a sane result set, but when I run curl from a Glitch console I get a different, suspect result.I’m going to have to take a closer look at this.

Thank you! This has been baffling me for a while now!

Hey @bryceremick, I think what’s happening here is that your project on Glitch is being rate-limited by; after a few repeated calls I see this in the output from curl: You are being watched. This is illegal behavior and will not be tolerated. We keep detailed logs of everything and will be reporting this to the FBI. If you would like mercy, email and apologize asap. If you note, that output begins with the letter “Y” as noted in your error message. It seems like the wrapper you’re using is a little fragile around assuming that the output from the API will always be JSON.

I’m reaching out to their support with respect to Glitch generally, but it might be worth you asking them if there’s something your project should be doing specifically to avoid this result.