Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
JS - Discord: parse external dynamic json content in array using axios

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!