このコミットが含まれているのは:
@@ -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 ()
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする