mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
26 lines
659 B
TypeScript
26 lines
659 B
TypeScript
import { readItems } from '@directus/sdk';
|
|
import { directusClient } from './directus';
|
|
|
|
|
|
|
|
export class layersApi {
|
|
mapId : string
|
|
|
|
constructor(mapId: string) {
|
|
this.mapId = mapId;
|
|
}
|
|
|
|
async getItems() {
|
|
try {
|
|
const layers = await directusClient.request(readItems("layers" as any, { fields: ['*', {itemType : ['*.*', {profileTemplate: ['*', 'item.*.*.*'] }]} as any], filter: { "maps": { "maps_id": { "id": { "_eq": this.mapId } } } }, limit: 500 }));
|
|
return layers;
|
|
} catch (error: any) {
|
|
console.log(error);
|
|
if (error.errors[0]?.message)
|
|
throw error.errors[0].message;
|
|
else throw error;
|
|
}
|
|
}
|
|
}
|
|
|