Initialize repo and add session changes (2025-09-08)
This commit is contained in:
15
resources/js/guest/services/photosApi.ts
Normal file
15
resources/js/guest/services/photosApi.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user