File size: 641 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { UseQueryResult, useQuery } from '@tanstack/react-query';
import { DomainDiagnostics } from 'calypso/lib/domains/types';
import wp from 'calypso/lib/wp';
import { domainDiagnosticsQueryKey } from './domain-diagnostics-query-key';

export default function useDomainDiagnosticsQuery(
	domainName: string,
	queryOptions = {}
): UseQueryResult< DomainDiagnostics > {
	return useQuery( {
		queryKey: domainDiagnosticsQueryKey( domainName ),
		queryFn: () =>
			wp.req.get( {
				path: `/domains/diagnostics/${ domainName }`,
				apiNamespace: 'wpcom/v2',
			} ),
		refetchOnWindowFocus: false,
		enabled: true,
		...queryOptions,
	} );
}