File size: 498 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import { numberFormatter } from "./number-formatter"
export async function getNpmDownloads() {
let count = 817_000 // Fallback if there's any error
try {
const data = await fetch(
"https://api.npmjs.org/downloads/point/last-month/@chakra-ui/react",
).then((res) => res.json())
count = data.downloads
} catch (error: any) {
console.log("Failed to get npm downloads: ", error.toString())
}
return {
count,
prettyCount: numberFormatter.format(count),
}
}
|