-1

I'm just working on the dashboard for my discord.js bot. I have created a variable to select the array from my JSON but the console tells me that the variable is undefined.

$(function() {
  $.getJSON( "./data/gameactivity.json", function(data) {
    $('#clickable').click(function() {
      /*if ($('#clickable').val() === "1") {
        console.log("yoyoyo");
      }*/
      if ($('#clickable').val() === data.value) {
        console.log(data);
      }
    })
    var i = data[0];
    console.log(i.value);
  })
});

Example of gameactivity.json:

{
    "gameactivity": [
        {"text": "ExampleBot is online", "value": "1"},
        {"text": "ExampleBot - !help", "value": "2"},
        {"text": "https://example.de", "value": "3"}
    ]
}

1 Answers1

0

You should get value from data.gameactivity[0]