このコミットが含まれているのは:
2026-10-26 12:19:43 +09:00
コミット 3e8f209542
31個のファイルの変更、1676行の追加、394行の削除
+25
ファイルの表示
@@ -199,3 +199,28 @@ export const apiDelete = async <T = void> (
export const isApiError = <T = unknown> (err: unknown): err is AxiosError<T> =>
axios.isAxiosError (err)
// Native downloads let the browser stream to disk without buffering a Blob in app memory.
export const apiDownload = async (
path: string,
body: Record<string, string>,
locale: LocaleCode,
): Promise<void> => {
const token = await csrfToken ()
const form = document.createElement ('form')
form.method = 'post'
form.action = `${API_BASE_URL}${path}?${new URLSearchParams ({ locale })}`
form.hidden = true
for (const [name, value] of Object.entries ({ ...body, authenticity_token: token }))
{
const input = document.createElement ('input')
input.type = 'hidden'
input.name = name
input.value = value
form.append (input)
}
document.body.append (form)
form.submit ()
form.remove ()
}