Skip to content

Commit

Permalink
refactor(useGenericRequest): rename response state to data and update…
Browse files Browse the repository at this point in the history
… related logic for clarity
  • Loading branch information
guidomodarelli committed Nov 5, 2024
1 parent 6523784 commit 037c943
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function useGenericRequest({
params = {},
resolveData = response => response,
}: UseGenericRequestProps) {
const [response, setResponse] = useState<any>({});
const [data, setData] = useState<any>({});
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState<Error>();

Expand All @@ -35,7 +35,7 @@ export function useGenericRequest({
path,
params,
);
setResponse(response);
setData(resolveData(response));
};
fetchData();
} catch (error) {
Expand All @@ -58,7 +58,7 @@ export function useGenericRequest({

return {
isLoading,
data: resolveData(response),
data,
error,
};
}

0 comments on commit 037c943

Please sign in to comment.