Skip to main content

LensStudio:AssetLibrary.GetAssetsByIdsResponse

Class

Response returned when fetching assets by IDs, containing matched assets or an error.

Index

Example

// GetAssetsByIdsResponse is returned by GetAssetsByIdsService.fetchAsync().
// It has a protected constructor — inspect it after a fetch.
const provider = this.pluginSystem.findInterface(
IAssetLibraryProvider.interfaceId
) as import('LensStudio:AssetLibrary').IAssetLibraryProvider;

const envSetting = new EnvironmentSetting();
envSetting.environment = Environment.Production;
envSetting.space = Space.Public;

// First, look up a valid id by searching the library.
const listFilter = new AssetFilter();
listFilter.searchText = 'material';
const listResponse = await provider.assetService.fetchAsync(
new AssetListRequest(envSetting, listFilter)
);
const ids = listResponse.ok && listResponse.data
? listResponse.data.assets.slice(0, 1).map(a => a.assetId)
: [];

// Then fetch those assets by id and inspect the response.
const response = await provider.assetsByIdsService.fetchAsync(
new GetAssetsByIdsRequest(envSetting, ids)
);

if (response.ok) {
console.log('Fetched by id, data:', response.data);
} else if (response.cancelled) {
console.log('Request was cancelled');
} else if (response.error) {
console.log('Error:', response.error.description);
}

Properties

cancelled

readonly cancelled: boolean

Indicates whether the request was cancelled before completing.


data?

readonly optional data?: any

Asset data returned by the request, if successful.


error?

readonly optional error?: ServiceError

Service error details if the request failed.


ok

readonly ok: boolean

True if the request completed successfully without errors.