Get data from a volatile layer

You can only get the latest published data from a volatile layer.

To get data from the volatile layer:

  1. Create the OlpClientSettings instance.

    For instructions, see Create platform client settings.

  2. Create the VolatileLayerClient object with the HERE Resource Name (HRN) of the catalog that contains the layer, the layer ID, and the platform client settings from step 1.

    const volatileLayerClient = await new VolatileLayerClient()
        hrn: "CatalogHRN",
        layerId: "LayerId",
        olpClientSettings
    );
    
  3. Create the DataRequest object with the partition ID and fetch option.

    The default fetch option is OnlineIfNotFound. It queries the network if the requested resource is not found in the cache. If you want to skip cache lookups and query the network right away, set the withFetchOption method to OnlineOnly.

    const dataRequest = new DataRequest()
      .withPartitionId("PartitionId")
      .withBillingTag("MyBillingTag")
      .withFetchOption(FetchOptions.OnlineOnly);
    
  4. Call the getData method with the DataRequest parameter.

    const partitions = await volatileLayerClient.getData(dataRequest);
    

You receive data from the requested partition of the selected volatile layer.

For examples, see Run the examples.

In browser and Node.js, to abort requests before they have completed, you can create the AbortController object, and then add the AbortController.signal property to your requests. For more information, see the AbortController documentation.

Example

const abortController = new AbortController();
const partitions = await volatileLayerClient.getData(
  dataRequest,
  abortController.signal
);

results matching ""

    No results matching ""