1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
unleash.unleash/frontend/src/hooks/api/actions/useFeatureApi/useFeatureApi.ts

32 lines
778 B
TypeScript
Raw Normal View History

import useAPI from '../useApi/useApi';
const useFeatureApi = () => {
const { makeRequest, createRequest, errors } = useAPI({
propagateErrors: true,
});
const changeFeatureProject = async (
projectId: string,
featureName: string,
newProjectId: string
) => {
const path = `api/admin/projects/${projectId}/features/${featureName}/changeProject`;
const req = createRequest(path, {
method: 'POST',
body: JSON.stringify({ newProjectId }),
});
try {
const res = await makeRequest(req.caller, req.id);
return res;
} catch (e) {
throw e;
}
};
return { changeFeatureProject, errors };
};
export default useFeatureApi;