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

104
Views
Call API have duplicate Data and output 500 arry

i need some help in my code

if see the visit api url you will see Large Data duplicated

const url = 'https://raw.githubusercontent.com/globaldothealth/monkeypox/main/latest.json';



async function getData() {
    const response = await fetch(url);
    const data = await response.json();
    console.log(data);

How we Can Merge all data and Sum it like to show have 500 infected named Confirmed And SUSPACKTED AND SHOW IT BY Numbar

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You simply need an object to store and count the cases while iterating over the array of persons. Find an implementation below:

const url =
  "https://raw.githubusercontent.com/globaldothealth/monkeypox/main/latest.json";

async function getData() {
  const response = await fetch(url);
  const data = await response.json();
  return data;
}

function getResults(data) {
  const results = {
    confirmed: 0,
    suspected: 0,
  };
  data.forEach((person) => {
    switch (person.Status) {
      case "confirmed":
        results.confirmed ++;
        break;
      case "suspected":
        results.suspected ++;
        break;
      default:
        break;
    }
  });
  return results;
}

(async function () {
  const data = await getData();
  const results = getResults(data);
  console.log(
    `${results.confirmed} confirmed cases\n${results.suspected} suspected cases.`
  );
})();

about 4 years ago · Juan Pablo Isaza Report
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!