| 12 | |
| 13 | // 🐨 rename this function to getShipImpl and remove the export |
| 14 | export async function getShip(name: string, delay?: number) { |
| 15 | const searchParams = new URLSearchParams({ name }) |
| 16 | if (delay) searchParams.set('delay', String(delay)) |
| 17 | const response = await fetch(`api/get-ship?${searchParams.toString()}`) |
| 18 | if (!response.ok) { |
| 19 | return Promise.reject(new Error(await response.text())) |
| 20 | } |
| 21 | const ship = await response.json() |
| 22 | return ship as Ship |
| 23 | } |
| 24 | |
| 25 | export function getImageUrlForShip( |
| 26 | shipName: string, |