Files
fotospiel-app/resources/js/guest/services/photosApi.ts
2025-09-08 14:03:43 +02:00

16 lines
407 B
TypeScript

import { getDeviceId } from '../lib/device';
export async function likePhoto(id: number): Promise<number> {
const res = await fetch(`/api/v1/photos/${id}/like`, {
method: 'POST',
headers: {
'X-Device-Id': getDeviceId(),
'Content-Type': 'application/json',
},
});
if (!res.ok) throw new Error('like failed');
const json = await res.json();
return json.likes_count ?? 0;
}