ChrisMichaelPerezSantiago / covid19

This API provides updated real-time data on coronavirus cases from the worldometers page, provided by the most reputable organizations and statistical offices in the world.
MIT License
76 stars 17 forks source link

GetReports() there isn't china #10

Closed AuroPick closed 4 years ago

AuroPick commented 4 years ago

I was trying take first 10 country. I tried this

corona.getReports().then(data => {
            for (let i = 0; i < 10 ; i++) {
                console.log(data[0][0].table[0][i]);    
            }

        })

but there wasn't china in the output output:

{
  TotalCases: '116,851',
  NewCases: '+12,725',
  TotalDeaths: '1,944',
  NewDeaths: '+248',
  TotalRecovered: '3,224',
  ActiveCases: '111,683',
  'Deaths/1M pop': '6',
  '1stcase': 'Jan 20',
  Country: 'USA',
  Serious_Critical: '2,666',
  TotCases_1M_Pop: '353'
}
{
  TotalCases: '92,472',
  NewCases: '+5,974',
  TotalDeaths: '10,023',
  NewDeaths: '+889',
  TotalRecovered: '12,384',
  ActiveCases: '70,065',
  'Deaths/1M pop': '166',
  '1stcase': 'Jan 29',
  Country: 'Italy',
  Serious_Critical: '3,856',
  TotCases_1M_Pop: '1,529'
}
{
  TotalCases: '72,248',
  NewCases: '+6,529',
  TotalDeaths: '5,812',
  NewDeaths: '+674',
  TotalRecovered: '12,285',
  ActiveCases: '54,151',
  'Deaths/1M pop': '124',
  '1stcase': 'Jan 30',
  Country: 'Spain',
  Serious_Critical: '4,165',
  TotCases_1M_Pop: '1,545'
}
{
  TotalCases: '56,202',
  NewCases: '+5,331',
  TotalDeaths: '403',
  NewDeaths: '+52',
  TotalRecovered: '6,658',
  ActiveCases: '49,141',
  'Deaths/1M pop': '5',
  '1stcase': 'Jan 26',
  Country: 'Germany',
  Serious_Critical: '1,581',
  TotCases_1M_Pop: '671'
}
{
  TotalCases: '37,575',
  NewCases: '+4,611',
  TotalDeaths: '2,314',
  NewDeaths: '+319',
  TotalRecovered: '5,700',
  ActiveCases: '29,561',
  'Deaths/1M pop': '35',
  '1stcase': 'Jan 23',
  Country: 'France',
  Serious_Critical: '4,273',
  TotCases_1M_Pop: '576'
}
{
  TotalCases: '35,408',
  NewCases: '+3,076',
  TotalDeaths: '2,517',
  NewDeaths: '+139',
  TotalRecovered: '11,679',
  ActiveCases: '21,212',
  'Deaths/1M pop': '30',
  '1stcase': 'Feb 18',
  Country: 'Iran',
  Serious_Critical: '3,206',
  TotCases_1M_Pop: '422'
}
{
  TotalCases: '17,089',
  NewCases: '+2,546',
  TotalDeaths: '1,019',
  NewDeaths: '+260',
  TotalRecovered: '135',
  ActiveCases: '15,935',
  'Deaths/1M pop': '15',
  '1stcase': 'Jan 30',
  Country: 'UK',
  Serious_Critical: '163',
  TotCases_1M_Pop: '252'
}
{
  TotalCases: '13,377',
  NewCases: '+449',
  TotalDeaths: '242',
  NewDeaths: '+11',
  TotalRecovered: '1,530',
  ActiveCases: '11,605',
  'Deaths/1M pop': '28',
  '1stcase': 'Feb 24',
  Country: 'Switzerland',
  Serious_Critical: '280',
  TotCases_1M_Pop: '1,546'
}
{
  TotalCases: '9,762',
  NewCases: '+1,159',
  TotalDeaths: '639',
  NewDeaths: '+93',
  TotalRecovered: '3',
  ActiveCases: '9,120',
  'Deaths/1M pop': '37',
  '1stcase': 'Feb 26',
  Country: 'Netherlands',
  Serious_Critical: '761',
  TotCases_1M_Pop: '570'
}
{
  TotalCases: '9,478',
  NewCases: '+146',
  TotalDeaths: '144',
  NewDeaths: '+5',
  TotalRecovered: '4,811',
  ActiveCases: '4,523',
  'Deaths/1M pop': '3',
  '1stcase': 'Jan 19',
  Country: 'S. Korea',
  Serious_Critical: '59',
  TotCases_1M_Pop: '185'
}
ChrisMichaelPerezSantiago commented 4 years ago

Good afternoon @AuroPick

I just checked and you're right, from what I see China is appearing in the second array of the table property table: [ [Array], [Array] ]

_The first array is the data for today and the second is for the data from the previous day._

It should be a bug or something, because it previously appeared in both arrays. 🤔

const f = async() =>{
  const data = await api.getReports();
  return Promise.all(data[0])
}

f()
  .then(res =>{
    console.log(res)
  });
[
  {
    cases: 657521,
    deaths: 30428,
    recovered: 141419,
    active_cases: [ [Object] ],
    closed_cases: [ [Object] ],
    table: [ [Array], [Array] ]
  }
]
ChrisMichaelPerezSantiago commented 4 years ago

@AuroPick

Eventually I will be checking the code.

Also, I noticed now that two new columns Deaths / 1M pop and 1stcase were added to the worldometers website. So I will have to correct both keys since one has space and the other has a number, and it is impossible for the dev to take the values.

If time permits, tomorrow I would have the changes.

ChrisMichaelPerezSantiago commented 4 years ago

@AuroPick ,

I was checking carefully, and yes, it shows the China data for both array.

What happens is that for some reason the data from China is appearing in the JSON almost at the end ..

You can verify it by doing a .filter(doc => doc.Country) and you will see that it is available.