File size: 807 Bytes
ec4551b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import { useIntegration } from '@gitroom/frontend/components/launches/helpers/use.integration';
import { useCallback } from 'react';
import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
export const useCustomProviderFunction = () => {
const { integration } = useIntegration();
const fetch = useFetch();
const get = useCallback(
async (funcName: string, customData?: any) => {
const load = await fetch('/integrations/function', {
method: 'POST',
body: JSON.stringify({
name: funcName,
id: integration?.id!,
data: customData,
}),
});
if (load.status > 299 && load.status < 200) {
throw new Error('Failed to fetch');
}
return load.json();
},
[integration]
);
return {
get,
};
};
|