MCPcopy Index your code
hub / github.com/nodeSolidServer/node-solid-server / fetchGraph

Method fetchGraph

lib/ldp.mjs:381–393  ·  view source on GitHub ↗

* Remotely loads the graph at a given uri, parses it and and returns it. * Usage: * * ``` * ldp.fetchGraph('https://example.com/contacts/card1.ttl') * .then(graph => { * // const matches = graph.match(...) * }) * ``` * * @param uri {string} Fully qua

(uri, options = {})

Source from the content-addressed store, hash-verified

379 * @return {Promise<Graph>}
380 */
381 async fetchGraph (uri, options = {}) {
382 const response = await fetch(uri)
383 if (!response.ok) {
384 const err = new Error(
385 `Error fetching ${uri}: ${response.status} ${response.statusText}`
386 )
387 err.statusCode = response.status || 400
388 throw err
389 }
390 const body = await response.text()
391
392 return parse(body, uri, getContentType(response.headers))
393 }
394
395 /**
396 * Remotely loads the graph at a given uri, parses it and and returns it.

Callers 1

Calls 2

parseFunction · 0.90
getContentTypeFunction · 0.90

Tested by

no test coverage detected