* 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 = {})
| 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. |
no test coverage detected