Files
portainer/app/react/docker/proxy/queries/secrets/useSecret.ts
T
2026-01-08 14:22:48 +13:00

22 lines
640 B
TypeScript

import { Secret } from 'docker-types';
import axios, { parseAxiosError } from '@/portainer/services/axios';
import { EnvironmentId } from '@/react/portainer/environments/types';
import { PortainerResponse } from '@/react/docker/types';
import { buildDockerProxyUrl } from '../buildDockerProxyUrl';
export async function getSecret(
environmentId: EnvironmentId,
id: NonNullable<Secret['ID']>
) {
try {
const { data } = await axios.get<PortainerResponse<Secret>>(
buildDockerProxyUrl(environmentId, 'secrets', id)
);
return data;
} catch (err) {
throw parseAxiosError(err, 'Unable to retrieve secret');
}
}