Files
yaak-mountain-loop/apps/yaak-client/hooks/useCopyHttpResponse.ts
T
2026-07-02 10:04:57 -07:00

17 lines
553 B
TypeScript

import type { HttpResponse } from "@yaakapp-internal/models";
import { copyToClipboard } from "../lib/copy";
import { getResponseBodyText } from "../lib/responseBody";
import { useFastMutation } from "./useFastMutation";
export function useCopyHttpResponse(response: HttpResponse | null) {
return useFastMutation({
mutationKey: ["copy_http_response", response?.id],
async mutationFn() {
if (response == null) return;
const body = await getResponseBodyText({ response, filter: null });
copyToClipboard(body);
},
});
}