import { useApi } from '~/composables/useApi' export type BovinDataResponse = | IdentificationBovinData | { 'hydra:member'?: IdentificationBovinData } export async function getBovinData( nationalNumber: string ): Promise { const api = useApi() const response = await api.get( `bovins/${nationalNumber}/identification`, {}, { toastErrorKey: 'errors.building.list' } ) if (response && typeof response === 'object') { // direct item if (!('hydra:member' in response)) return response as IdentificationBovinData // hydra format if (response['hydra:member']) return response['hydra:member'] } return null }