1
0
Fork 0
VaultUI/src/api/getTransitKeys.ts

17 lines
505 B
TypeScript
Raw Normal View History

2021-05-07 23:35:43 +01:00
import { DoesNotExistError } from "../types/internalErrors";
2021-05-08 00:21:58 +01:00
import { appendAPIURL, getHeaders } from "./apiUtils";
2021-05-07 11:53:26 +01:00
2021-05-08 00:21:58 +01:00
export async function getTransitKeys(baseMount: string): Promise<string[]> {
2021-05-07 11:53:26 +01:00
const request = new Request(appendAPIURL(`/v1/${baseMount}/keys?list=true`), {
headers: getHeaders(),
});
return fetch(request).then(response => {
if (response.status == 404) {
throw DoesNotExistError;
}
return response.json();
}).then(data => {
return data.data.keys;
});
}