( input: RequestInfo, init?: RequestInit, )
| 6 | const sessionApiRoute = '/session' |
| 7 | |
| 8 | async function fetchJson<JSON = unknown>( |
| 9 | input: RequestInfo, |
| 10 | init?: RequestInit, |
| 11 | ): Promise<JSON> { |
| 12 | return fetch(input, { |
| 13 | headers: { |
| 14 | accept: 'application/json', |
| 15 | 'content-type': 'application/json', |
| 16 | }, |
| 17 | ...init, |
| 18 | }).then((res) => res.json()) |
| 19 | } |
| 20 | |
| 21 | function doLogin(url: string, { arg }: { arg: string }) { |
| 22 | return fetchJson<SessionData>(url, { |