mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
34 lines
835 B
TypeScript
34 lines
835 B
TypeScript
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
/* eslint-disable no-console */
|
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
import { readItems } from '@directus/sdk'
|
|
|
|
import { directusClient } from './directus'
|
|
|
|
export class mapApi {
|
|
url: string
|
|
|
|
constructor(url: string) {
|
|
this.url = url
|
|
}
|
|
|
|
async getItems() {
|
|
try {
|
|
const map = await directusClient.request(
|
|
readItems('maps' as any, {
|
|
fields: ['*'],
|
|
filter: { url: { _eq: this.url } } as any,
|
|
limit: 500,
|
|
}),
|
|
)
|
|
if (map[0]) return map[0]
|
|
else return 'null'
|
|
} catch (error: any) {
|
|
console.log(error)
|
|
if (error.errors[0]?.message) throw error.errors[0].message
|
|
else throw error
|
|
}
|
|
}
|
|
}
|