mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-05-18 07:28:31 -05:00
use async for status page fetch
This commit is contained in:
@@ -11,18 +11,21 @@ const useStatusPagesFetch = () => {
|
||||
const [statusPages, setStatusPages] = useState(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
try {
|
||||
networkService
|
||||
.getStatusPagesByTeamId({ authToken, teamId: user.teamId })
|
||||
.then((res) => {
|
||||
setStatusPages(res.data.data);
|
||||
const fetchStatusPages = async () => {
|
||||
try {
|
||||
const res = await networkService.getStatusPagesByTeamId({
|
||||
authToken,
|
||||
teamId: user.teamId,
|
||||
});
|
||||
} catch (error) {
|
||||
setNetworkError(true);
|
||||
createToast(error.message, "error");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
setStatusPages(res?.data?.data);
|
||||
} catch (error) {
|
||||
setNetworkError(true);
|
||||
createToast(error.message, "error");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
fetchStatusPages();
|
||||
}, [authToken, user]);
|
||||
return [isLoading, networkError, statusPages];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user