import { omit } from 'lodash-es' import { httpConfig } from '~/config' interface DeviceStatus { floor: string unit: string device: string room: string devType: string code: string tower: string payload: string topics?: unknown createAt?: unknown } export async function queryDeviceStatus(topic: string): Promise | null> { const response = await fetch(`${httpConfig.baseUrl}/state-reply`, { method: 'POST', body: JSON.stringify({ topic }), headers: { 'Content-Type': 'application/json', }, }) if (!response.ok) { throw new Error('internal_server_error') } const json = await response.json() if (!json || !json.data) { return null } return omit(json.data as DeviceStatus, ['topics', 'createAt']) }