fix api /me

This commit is contained in:
Mikola
2023-12-25 20:58:18 +03:00
parent 5e7c9dec79
commit 80ebf85347
3 changed files with 29 additions and 27 deletions

View File

@ -20,21 +20,21 @@ export const ProfileHeader = () => {
const [isLoggingOut, setIsLoggingOut] = useState(false);
useEffect(() => {
if (Object.keys(profileInfo).length) {
return;
}
apiRequest(`/user/me`).then((profileInfo) => {
dispatch(
setProfileInfo(
profileInfo.userCard ? profileInfo.userCard : profileInfo
)
);
});
}, [dispatch]);
// useEffect(() => {
// if (Object.keys(profileInfo).length) {
// return;
// }
// apiRequest(`/user/me`).then((profileInfo) => {
// dispatch(
// setProfileInfo(
// profileInfo.userCard ? profileInfo.userCard : profileInfo
// )
// );
// });
// }, [dispatch]);
useEffect(() => {
apiRequest(`/user/me`).then((profileInfo) => {
if (!Object.keys(profileInfo).length) apiRequest(`/user/me`).then((profileInfo) => {
dispatch(
setProfileInfo(
profileInfo.userCard ? profileInfo.userCard : profileInfo
@ -49,6 +49,7 @@ export const ProfileHeader = () => {
dispatch(auth(false));
setIsLoggingOut(false);
navigate("/auth");
dispatch(setProfileInfo({}))
};
return (