MCPcopy
hub / github.com/github/docs / getDOM

Function getDOM

tests/helpers/e2etest.js:71–89  ·  view source on GitHub ↗
(
  route,
  { headers, allow500s, allow404 } = {
    headers: undefined,
    allow500s: false,
    allow404: false,
  }
)

Source from the content-addressed store, hash-verified

69}
70
71export async function getDOM(
72 route,
73 { headers, allow500s, allow404 } = {
74 headers: undefined,
75 allow500s: false,
76 allow404: false,
77 }
78) {
79 const res = await get(route, { followRedirects: true, headers })
80 if (!allow500s && res.status >= 500) {
81 throw new Error(`Server error (${res.status}) on ${route}`)
82 }
83 if (!allow404 && res.status === 404) {
84 throw new Error(`Page not found on ${route}`)
85 }
86 const $ = cheerio.load(res.text || '', { xmlMode: true })
87 $.res = Object.assign({}, res)
88 return $
89}
90
91// For use with the ?json query param
92// e.g. await getJSON('/en?json=breadcrumbs')

Callers 15

early-access.jsFile · 0.90
footer.jsFile · 0.90
internal-links.jsFile · 0.90
featured-links.jsFile · 0.90
release-notes.jsFile · 0.90
sidebar.jsFile · 0.90
head.jsFile · 0.90
page-titles.jsFile · 0.90
rest.jsFile · 0.90

Calls 1

getFunction · 0.85

Tested by

no test coverage detected