(id: string, item: ItemWrapper, versionIdx: number)
| 17 | const API_HOST = (import.meta.env.VITE_API_HOST ?? '/v1') as string |
| 18 | |
| 19 | export async function share(id: string, item: ItemWrapper, versionIdx: number) { |
| 20 | const r = await fetch(`${API_HOST}/share/${id}`, { |
| 21 | method: 'POST', |
| 22 | headers: { |
| 23 | 'Content-Type': 'application/json' |
| 24 | }, |
| 25 | body: JSON.stringify({ |
| 26 | prompt: item.prompt(versionIdx), |
| 27 | html: item.pureHTML(versionIdx), |
| 28 | name: item.name, |
| 29 | emoji: item.emoji |
| 30 | }) |
| 31 | }) |
| 32 | if (r.status !== 201) { |
| 33 | const body = (await r.json()) as ErrorBody |
| 34 | throw new Error(body.error.message) |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | export async function voteRequest( |
| 39 | vote: boolean, |
no test coverage detected