bigbuffet-rw/app/soapbox/entity-store/hooks/useEntityRequest.ts
2023-03-23 18:44:44 -05:00

21 lines
No EOL
459 B
TypeScript

import { useApi, useLoading } from 'soapbox/hooks';
import { EntityRequest } from './types';
import { toAxiosRequest } from './utils';
function useEntityRequest() {
const api = useApi();
const [isLoading, setPromise] = useLoading();
function request(entityRequest: EntityRequest) {
const req = api.request(toAxiosRequest(entityRequest));
return setPromise(req);
}
return {
request,
isLoading,
};
}
export { useEntityRequest };