25 lines
641 B
TypeScript
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 ?? [];
|
|
}
|