covidtracker
Version:
An Api wrapper to get information about the Novel Coronavirus.
93 lines (60 loc) • 2.32 kB
Markdown
View information on the Coronavirus outbreak around the world.
*Updated By: [Apollo
- Updated the API Wrapper to V2 of https://corona.lmao.ninja/v2/
  [](https://discord.gg/tTEBTxR)
[](https://www.npmjs.com/package/covidtracker)
Stable Release (`v2.0.1`)
```js
npm i covidtracker@2.0.1
```
### Methods
**.getAll()**
**.getCountry({country, sort})**
**.getState({state, sort})**
**.getHistoric({country, province})**
**.getJHU({country, province, sort})**
## Loading and using the module
We suggest you load the module via `require`, pending the stabalizing of es modules in node:
```js
const covid = require('covidtracker');
```
To actually use the data, you will need an [async/await](https://javascript.info/async-await).
```js
// Declare the package
const covid = require('covidtracker');
// Now we create a async/await
(async () => {
// Now we await it.
let all = await covid.getAll();
// Make sure you return it, this usually implies if you are using this inside a function.
// Use \n to break lines.
return console.log(`Cases: ${all.cases}\nDeaths: ${all.deaths}\nRecovered: ${all.recovered}`)
})()
```
Some [methods](https://www.npmjs.com/package/covidtracker#methods) can be sorted.
```js
const covid = require('covidtracker');
(async () => {
let sortedCountries = await covid.getCountry({sort: 'recovered'});
return console.log(sortedCountries);
let sortedStates = await covid.getState({sort: 'deaths'});
return console.log(sortedStates);
})();
```
```js
const covid = require('covidtracker');
(async () => {
// Specific Country
let specificCountry = await covid.getCountry({country: 'United States'});
return console.log(specificCountry);
// Specific State
let specificState = await covid.getState({state: 'New York'});
return console.log(specificCountry);
})();
```