-
I’ve created this Twitch chatbot that uses League of Legend’s API through a URL in JSON, you can check out more about that in here: https://developer.riotgames.com/apis#league-v4/GET_getLeagueEntriesForSummoner Here is the whole code:
All that code is running inside a VPS with Forever. What happens is that the getJSON function always returns “undefined” no matter what URL it’s used. At first, I thought it could’ve something to do with XHR running in Async, but as far as I know, my code is taking care of that with no problem. I also tried running the code in a LocalHost with Node.js on my computer just to see if the problem would be related to the VPS being on Linux instead of Windows, but the problem stood exactly the same. Keep in mind that the variable LeagueURL and the local JSON files are NOT the problems, so you can get that out of the way. Important parts of the code that are most likely related to the problem: Creating the getJSON function:
Using the getJSON function:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hello, @infinite-dreams . I couldn’t find the solution to the problem, however, I found a different approach to what I wanted to do. I decided to throw the whole XMLHttpRequest away and tried using fetch. It worked. Here is the code solution:
|
Beta Was this translation helpful? Give feedback.
-
Awesome! I’ll keep that in mind the next time I do JavaScript 😃. |
Beta Was this translation helpful? Give feedback.
Hello, @infinite-dreams .
I couldn’t find the solution to the problem, however, I found a different approach to what I wanted to do.
I decided to throw the whole XMLHttpRequest away and tried using fetch. It worked.
Here is the code solution: