Giter VIP home page Giter VIP logo

Comments (4)

kimmming avatar kimmming commented on August 18, 2024

import { authAtom, accountNameAtom} from '../../atom/atoms';
import { useRecoilValue } from 'recoil';

const auth = useRecoilValue(authAtom);
const accountname = useRecoilValue(accountNameAtom);


auth 에 토큰
accountname 에 accountname
애플리케이션 - 로컬스토리지에서 확인할 수 있는데 이게 맞는지 잘 몰르겟어요
근데 token 으로 넣엇던 곳을 auth 변수로 고치면 작동 잘되어여

from final-11-nigonego.

kimmming avatar kimmming commented on August 18, 2024

HomeFeed랑 PostUpload 에 있던 token 값을 auth로 바꿧음

from final-11-nigonego.

kimmming avatar kimmming commented on August 18, 2024

token 저장되어 있으면 바로 HomeFeed 아니면 LoginMain
STartSplash.jsx 수정 하였습니다.

  return loading ? (
    <SplashPage />
  ) : auth && accountname ? (
    <HomeFeed />
  ) : (
    <LoginMain />
  );

from final-11-nigonego.

kimmming avatar kimmming commented on August 18, 2024

LoginPage.jsx
FollowerData 함수 만들어서 following 없으면 home 으로, 있으면 homefeed로

   setAuth(token);
        setAccountname(accountname);
        await FollowerData(token);
        
       async function FollowerData(token) {
    try {
      const res = await axios.get(`${url}/user/myinfo`, {
        headers: {
          Authorization: `Bearer ${token}`,
        },
      });
      const { following } = res.data.user;
      setFollowing(following);
      if (Object.keys(following).length === 0) {
        navigate('/home');
      } else {
        navigate('/homefeed');
      }
    } catch (error) {
      console.error(error);
    }
  }

from final-11-nigonego.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.