0
                request(getuser, function(err, res, body) {
                    let user = JSON.parse(body);
                    if (true) {
                        var groups = Object.keys(user.groups).length - 1;
                    }
                })

How can I acces groups from anywhere? I tried the above code but I can not acces it here:

            let founduser = new Discord.RichEmbed()
            .addField("Amount of groups", groups)
Dais
  • 3
  • 1
  • `groups` is being defined asynchronously, so even if you fix the scoping you won't be able to get the value until after the request returns. And why the `if(true)`? – Mark Jul 06 '18 at 20:09
  • @MarkMeyer Tried to acces it when the code is running (true), do you have a code example to make the above work so I can use it in the future? I am fairly new to js – Dais Jul 06 '18 at 20:11

0 Answers0