| 11 | } |
| 12 | |
| 13 | export async function fetchNotes(params: { youtubeId: string }): Promise<Note[]> { |
| 14 | const query = new URLSearchParams(); |
| 15 | query.set('youtubeId', params.youtubeId); |
| 16 | |
| 17 | const response = await csrfFetch.get(`/api/notes?${query.toString()}`); |
| 18 | |
| 19 | if (!response.ok) { |
| 20 | throw new Error('Failed to fetch notes'); |
| 21 | } |
| 22 | |
| 23 | const data = await response.json(); |
| 24 | return (data.notes || []) as Note[]; |
| 25 | } |
| 26 | |
| 27 | export async function saveNote(payload: SaveNotePayload): Promise<Note> { |
| 28 | const response = await csrfFetch.post('/api/notes', payload); |