I have a dynamic json with a constant field that gaves me the number of fields to read, with the other fields that increase time by time when someone make changes. assume that
{ "number":"xxx",
"n1":"some text1",
"n2":"some text2",
[and so on, based on the number cointained in "number"]
}
I want to create a response in discord like
"There are xxx entries"
"Entry n.1 - (..)"
"Entry n.2 - (..)"
and so on.
The code I made is
let nrlink = 'MY SITE - json';
let {data} = await axios(nrlink);
let nr_set = data.number;
let sets = [];
let i = 1;
while (i <= nr_set) {
sets += data.n + i; <-This doesn't work
i++;
}
await lib.discord.channels['@0.2.0'].messages.create({
content: "There are" + nr_set + " entries\n" +
data.n1 + "\n" + sets
channel_id: context.params.event.channel_id,
});
So, if I point directly the data, like data.n1, it works. Array 'sets' doesn't work, I can't populate using "data.n + i" to create the pointing to "data.n1" or "data.n2"
Is there a way to make that?
Thanks