Skip to content

Commit

Permalink
Merge pull request #55 from 2022-2-Graduation-Project/feature/37-logi…
Browse files Browse the repository at this point in the history
…n-signup

[#37] fix: add json parse to user object
  • Loading branch information
suzinxix authored Feb 21, 2023
2 parents 35ea398 + 4892495 commit 71035c7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bowwowcare/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import EventBus from "./common/EventBus";
function App() {
const { user: currentUser } = useSelector((state) => state.auth);
const dispatch = useDispatch();
const token = window.localStorage.getItem("user")
const token = JSON.parse(localStorage.getItem("user"))?.token

const logOut = useCallback(() => {
dispatch(logout());
Expand Down
2 changes: 1 addition & 1 deletion bowwowcare/src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function Header() {
{window.location.pathname==="/login" ? (
null
) : (
window.localStorage.getItem("user") ? (
JSON.parse(localStorage.getItem("user")) ? (
<button className="text-right" onClick={() => dispatch(logout())}>로그아웃</button>
) : (
<button className="text-right" onClick={handleLogin}>로그인</button>
Expand Down
2 changes: 1 addition & 1 deletion bowwowcare/src/views/HomePage/PetList/PetList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Link, useNavigate } from "react-router-dom";
import PetInfo from "./Sections/PetInfo";

function PetList(props) {
const user = window.localStorage.getItem("user");
const user = JSON.parse(localStorage.getItem("user"));
const navigate = useNavigate();
return user ? (
<div className="flex overflow-x-scroll">
Expand Down

0 comments on commit 71035c7

Please sign in to comment.