Connected version history to backend

This commit is contained in:
Vladyslav Matsiiako
2022-12-27 15:02:50 -05:00
parent 2c63559303
commit bb4d3ba581
5 changed files with 425 additions and 20 deletions
@@ -0,0 +1,40 @@
import SecurityClient from '~/utilities/SecurityClient';
interface secretVersionProps {
secretId: string;
offset: number;
limit: number;
}
/**
* This function fetches the versions of a specific secret
* @param {object} obj
* @param {string} obj.secretId - the id of a secret for which we are fetching the version history
* @param {number} obj.offset - the start of our query
* @param {number} obj.limit - how far our query goes
* @returns
*/
const getSecretVersions = async ({ secretId, offset, limit }: secretVersionProps) => {
return SecurityClient.fetchCall(
'/api/v1/secret/' + secretId + '/secret-versions?'+
new URLSearchParams({
offset: String(offset),
limit: String(limit)
}),
{
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
}
).then(async (res) => {
if (res && res.status == 200) {
return await res.json();
} else {
console.log('Failed to get project secrets');
}
});
};
export default getSecretVersions;