Use https://covid19api.com/ API which provide data from Johns Hopkins CSSE
This R api package was created was created using the httr()
vignette
Best practices for API packages
You can install covid19api package with:
remotes::install_github("nekrum/covid19api")
This is a basic example which shows you how to solve a common problem:
library(covid19api)
GetCountrySummary()