UNPKG

arredemo

Version:

Instantly build a static site for your package

15 lines (11 loc) 386 B
import fetch from "node-fetch" import getPkgFileUrl from "./getPkgFileUrl.mjs" export default async function fetchPkgFile(pkgName, version, filename = "README.md") { const url = getPkgFileUrl(pkgName, version, filename) const resp = await fetch(url) if (resp.status !== 200) { throw new Error(`Unable to fetch file ${url}`) } const md = await resp.text() return md }