You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/react/docker/proxy/queries/nodes/useNodes.ts

22 lines
702 B

import { Node } from 'docker-types/generated/1.41';
import { useQuery } from 'react-query';
import axios, { parseAxiosError } from '@/portainer/services/axios';
import { EnvironmentId } from '@/react/portainer/environments/types';
import { buildUrl } from './build-url';
import { queryKeys } from './query-keys';
export function useNodes(environmentId: EnvironmentId) {
return useQuery(queryKeys.base(environmentId), () => getNodes(environmentId));
}
async function getNodes(environmentId: EnvironmentId) {
try {
const { data } = await axios.get<Array<Node>>(buildUrl(environmentId));
return data;
} catch (error) {
throw parseAxiosError(error, 'Unable to retrieve nodes');
}
}