COVID-19-Dashboard icon indicating copy to clipboard operation
COVID-19-Dashboard copied to clipboard

Widget shows error because hospitalization API returns error object

Open 0xbs opened this issue 2 years ago • 11 comments

Widget in version 1.10.0 shows an error message if used with vac=y:

Error on line 648:61: TypeError: undefined is not an object (evaluating 'hospitalizationData.data[bundesLand]")

Underlying issue is the API for hospitalization rates https://api.corona-zahlen.org/states which returns the following error:

{"error":{"message":"There is a problem with the official RKI API.","rkiError":{"code":400,"message":"","details":["Unable to perform query. Please check your parameters."]},"url":"https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_COVID19/FeatureServer/0/query?where=NeuGenesen IN(1,0)&objectIds=&time=&resultType=standard&outFields=AnzahlGenesen,MeldeDatum,IdBundeland&returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnDistinctValues=false&cacheHint=false&orderByFields=IdBundesland&groupByFieldsForStatistics=IdBundesland&outStatistics=[{\"statisticType\":\"sum\",\"onStatisticField\":\"AnzahlGenesen\",\"outStatisticFieldName\":\"recovered\"},{\"statisticType\":\"max\",\"onStatisticField\":\"MeldeDatum\",\"outStatisticFieldName\":\"date\"}]&having=&resultOffset=&resultRecordCount=&sqlFormat=none&f=json&token="}}

The response should be checked for an error object and not only for a truthy value.

Also an option to switch off the hospitalization rates would be desirable.

0xbs avatar Nov 08 '21 15:11 0xbs

Thanks for debugging 😉

As for the incident at hand, see https://github.com/marlon360/rki-covid-api/issues/321

As for the error handling: Yes, I'm aware that this is quick and dirty … and I'm not particularly proud of it 😉

As for the switch for the hospitalization: This is definitely feasible and on my list.

marcusraitner avatar Nov 08 '21 18:11 marcusraitner

Turning of hospitalization is now possible in the latest version on master with param hosp=n … at least a workaround until the API is fixed.

marcusraitner avatar Nov 08 '21 19:11 marcusraitner

The API works now fine again.

marcusraitner avatar Nov 09 '21 07:11 marcusraitner

See also https://github.com/marlon360/rki-covid-api/issues/319

marcusraitner avatar Nov 09 '21 07:11 marcusraitner

Hello,

this error occurres again, I am getting: 2022-01-09 08:41:48: Getting hospitalization data: https://api.corona-zahlen.org/states 2022-01-09 08:41:48: {"error":{"message":"An error occurred while fetching external data.","details":"connect ETIMEDOUT 185.199.108.133:443","url":"https://raw.githubusercontent.com/robert-koch-institut/COVID-19-Hospitalisierungen_in_Deutschland/master/.zenodo.json","stack":"Error: connect ETIMEDOUT 185.199.108.133:443\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16)\n at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17)"}} 2022-01-09 08:41:48: Error on line 987:63: TypeError: undefined is not an object (evaluating 'hospitalizationData.data[bundesLand]')

I use 1.11.0

BG Markus P.S. Great Script!

SpeedmaxX avatar Jan 09 '22 07:01 SpeedmaxX

Same here. Use hosp=n as parameter as a workaround until the API is fixed (probably the RKI once again changed their Excel 🧐)

marcusraitner avatar Jan 09 '22 07:01 marcusraitner

Ok. In the meantime I did this ` if (debug) { console.log("hospi"); console.log(hospitalizationData.error); console.log(hospitalizationData); // console.log(bundesland); }

  if (!hospitalizationData || hospitalizationData.error) {
    list.addText('Keine Hospitalisierungsdaten.');
    return list;
  } `

I also got „bundesland is undefined“ then

SpeedmaxX avatar Jan 09 '22 07:01 SpeedmaxX

but location-call-result seems good

`

2022-01-09 09:01:27: location 2022-01-09 09:01:27: {"GEN":"Borken","EWZ_BL":17925570,"death_rate":1.25835938427446,"cases":25271,"deaths":318,"cases7_bl_per_100k":351.006969373917,"EWZ":371898,"BL":"Nordrhein-Westfalen","county":"LK Borken","cases7_per_100k":362.196086023587,"AGS":"05554"}

`

SpeedmaxX avatar Jan 09 '22 08:01 SpeedmaxX

Yes. Everything else is working. Your suggestion for improving error handling is good. As for the variable holding the "Bundesland" it is bundesLand with a capital L (do not ask me why …)

marcusraitner avatar Jan 09 '22 08:01 marcusraitner

Thanks, editing on the phone is sometimes hard…

SpeedmaxX avatar Jan 09 '22 08:01 SpeedmaxX

Sure. However, bundesLand is quite unconventional with the capital L … should correct this.

marcusraitner avatar Jan 09 '22 10:01 marcusraitner