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/common/stacks/queries/useStacks.ts

24 lines
640 B

import { useQuery } from '@tanstack/react-query';
import { withError } from '@/react-tools/react-query';
import axios, { parseAxiosError } from '@/portainer/services/axios';
import { Stack } from '@/react/common/stacks/types';
import { buildStackUrl } from './buildUrl';
import { queryKeys } from './query-keys';
export function useStacks() {
return useQuery(queryKeys.base(), () => getStacks(), {
...withError('Failed loading stack'),
});
}
export async function getStacks() {
try {
const { data } = await axios.get<Stack[]>(buildStackUrl());
return data;
} catch (e) {
throw parseAxiosError(e as Error);
}
}