disease-sh/node-api

Fix "sort by" parameter in NPM package

SteveMHoward opened this issue · 1 comments

I am using the latest version of the NPM package (1.1.2) and was experiencing the same issue that I have seen posted a few times that China was appearing at the bottom of the list, even though I was telling it to sort by cases:
await this.covid.countries(null, 'cases' );

Looking through the NPM package, it looks like I needed to explicitly add the sort= in the parameter:
await this.covid.countries(null, 'sort=cases' );

This works, but VS Code complains that this is wrong since the index.d.ts doesn't expect the sort=

Argument of type '"sort=cases"' is not assignable to parameter of type '"cases" | "todaysCases" | "deaths" | "recovered" | "active" | "critical" | "casesPerOneMillion" | "deathsPerOneMillion"'.ts(2345)

I assume this will be a quick fix in index.js changing
return node_fetch_1.default(${this.baseURL}/countries?${sort}).then(json);
to
return node_fetch_1.default(${this.baseURL}/countries?sort=${sort}).then(json);

P.S. Thanks for the fantastic API! 👍

Thanks for the heads up! I have fixed it will release a new version soon!