Files
fotospiel-app/resources/js/guest-v2/services/emotionsApi.ts
2026-02-02 13:01:20 +01:00

25 lines
641 B
TypeScript

import { fetchJson } from './apiClient';
import { getDeviceId } from '../lib/device';
export type EmotionItem = Record<string, unknown>;
type EmotionResponse = {
data?: EmotionItem[];
};
export async function fetchEmotions(eventToken: string, locale?: string) {
const params = new URLSearchParams();
if (locale) params.set('locale', locale);
const response = await fetchJson<EmotionResponse>(
`/api/v1/events/${encodeURIComponent(eventToken)}/emotions${params.toString() ? `?${params.toString()}` : ''}`,
{
headers: {
'X-Device-Id': getDeviceId(),
},
}
);
return response.data?.data ?? [];
}