(name: string, delay?: number)
| 3 | export type { Ship } |
| 4 | |
| 5 | export async function getShip(name: string, delay?: number) { |
| 6 | const searchParams = new URLSearchParams({ name }) |
| 7 | if (delay) searchParams.set('delay', String(delay)) |
| 8 | const response = await fetch(`api/get-ship?${searchParams.toString()}`) |
| 9 | if (!response.ok) { |
| 10 | return Promise.reject(new Error(await response.text())) |
| 11 | } |
| 12 | const ship = await response.json() |
| 13 | return ship as Ship |
| 14 | } |
| 15 | |
| 16 | export function getImageUrlForShip( |
| 17 | shipName: string, |