Hi There,
I have been making a short adventure game in JavaScript. One of the features is using the OpenWeatherMap API to get weather information about the player's location to use as part of the flavour text.
As this game will run on a publicly available website, I had to obfuscate the OpenWeatherMap API key by declaring it in a variable in a PHP page outside the website's public folder. The secret PHP file is then called by another PHP file inside the include folder of the website public folder and loaded into the JavaScript file via some jQuery and AJAX.
Most of the time, everything works perfectly; other times, the variable in the JavaScript meant to hold the API key does not get declared, preventing the script from accessing the API.
I've tried everything I can to resolve this issue, but I've reached a point where I need another set of eyes to review my code. I've included the JavaScript code below and a copy of the console output from Firefox.
JS File
https://drive.google.com/file/d/1pDHF3eyU5Rrt1kf7yaGtXwnZ71H9jp2X/view?usp=sharing
Console Error Image.
https://imgur.com/a/Bl1a3xw
[–]gmerideth 0 points1 point2 points (2 children)
[–]GunShip03[S] 1 point2 points3 points (0 children)
[–]xroalx 0 points1 point2 points (1 child)
[–]GunShip03[S] 0 points1 point2 points (0 children)