Files
yaak/src-web/lib/responseBody.ts
2023-11-21 22:15:01 -08:00

17 lines
495 B
TypeScript

import { readBinaryFile, readTextFile } from '@tauri-apps/api/fs';
import type { HttpResponse } from './models';
export async function getResponseBodyText(response: HttpResponse): Promise<string | null> {
if (response.bodyPath) {
return await readTextFile(response.bodyPath);
}
return null;
}
export async function getResponseBodyBlob(response: HttpResponse): Promise<Uint8Array | null> {
if (response.bodyPath) {
return readBinaryFile(response.bodyPath);
}
return null;
}