mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
32 lines
778 B
TypeScript
32 lines
778 B
TypeScript
|
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;
|