Skip to content

Function: readResource

readResource(uri, options?): Promise\<ReadLeafResult>

Reads resource at a provided URI and returns the result

Parameters

Name Type Description
uri LeafUri The URI of the resource
options? DatasetRequestOptions Options to provide a fetch function and a local dataset to update.

Returns

Promise\<ReadLeafResult>

ReadResult

Example

import { deleteResource } from "@ldo/solid";
import { createDataset } from "@ldo/dataset"
import { fetch } from "@inrupt/solid-client-autn-js";

const dataset = createDataset();
const result = await readResource(
  "https://example.com/container/someResource.ttl",
  { fetch, dataset },
);
if (!result.isError) {
  if (result.type === "absentReadSuccess") {
    // There was no problem reading the resource, but it doesn't exist
  } else if (result.type === "dataReadSuccess") {
    // The resource was read and it is an RDF resource. The dataset provided
    // dataset will also be loaded with the data from the resource
  } else if (result.type === "binaryReadSuccess") {
    // The resource is a binary
    console.log(result.blob);
    console.log(result.mimeType);
  }
}

Defined in

packages/solid/src/requester/requests/readResource.ts:83

readResource(uri, options?): Promise\<ReadContainerResult>

Parameters

Name Type
uri ContainerUri
options? DatasetRequestOptions

Returns

Promise\<ReadContainerResult>

Defined in

packages/solid/src/requester/requests/readResource.ts:87

readResource(uri, options?): Promise\<ReadLeafResult | ReadContainerResult>

Parameters

Name Type
uri string
options? DatasetRequestOptions

Returns

Promise\<ReadLeafResult | ReadContainerResult>

Defined in

packages/solid/src/requester/requests/readResource.ts:91