MCPcopy Create free account
hub / github.com/github/docs / getPage

Function getPage

script/domwaiter.js:34–55  ·  view source on GitHub ↗
(page, emitter, opts)

Source from the content-addressed store, hash-verified

32}
33
34async function getPage(page, emitter, opts) {
35 emitter.emit('beforePageLoad', page)
36
37 if (opts.json) {
38 try {
39 const json = await got(page.url).json()
40 const pageCopy = Object.assign({}, page, { json })
41 emitter.emit('page', pageCopy)
42 } catch (err) {
43 emitter.emit('error', err)
44 }
45 } else {
46 try {
47 const body = (await got(page.url)).body
48 const pageCopy = Object.assign({}, page, { body })
49 if (opts.parseDOM) pageCopy.$ = cheerio.load(body)
50 emitter.emit('page', pageCopy)
51 } catch (err) {
52 emitter.emit('error', err)
53 }
54 }
55}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected