Files
yaak-mountain-loop/src-web/hooks/useResponseContentType.ts
2023-04-13 18:48:40 -07:00

10 lines
310 B
TypeScript

import { useMemo } from 'react';
import type { HttpResponse } from '../lib/models';
export function useResponseContentType(response: HttpResponse | null): string | null {
return useMemo(
() => response?.headers.find((h) => h.name.toLowerCase() === 'content-type')?.value ?? null,
[response],
);
}