| 1 | import createFetchClient from "openapi-fetch"; |
| 2 | import type { paths |
| 3 | import { API_URL } |
| 4 | |
| 5 | /** Typed API client for client components. Unlike the server one, the browser carries the session cookie itself - it only has to be asked to. */ |
| 6 | export const apiClient = |
| 7 | baseUrl: API_URL, |
| 8 | credentials: "include", |
| 9 | }); |
| 10 | |
| 11 | /** The message the API's error filter returns, or a status-code fallback. */ |
| 12 | export function apiErrorMessage( |
| 13 | error: unknown, |
| 14 | fallback = "Something went wrong" |
| 15 | ) { |
| 16 | const message = |
| 17 | return typeof message |
| 18 | } |