import { components } from './schema.ts' // TODO for now we just assume that the API and client are running on the same host // i think this might change but dependes on what we do with deployment const ApiHost = `http://${location.hostname}:5181` console.debug('API HOST IS', ApiHost) export async function loadPostsForAuthor( authorId: string, count?: number, cursor?: string, ): Promise { const url = new URL(`authors/${authorId}/posts`, ApiHost) if (count != null) url.searchParams.set('count', count.toString()) if (cursor) url.searchParams.set('cursor', cursor) const request = new Request(url) const response = await fetch(request) if (!response.ok) throw new Error(await response.text()) return await response.json() }