src/App.js
//each time app mounts checks to see if authorized to access so you don't have to login again
each time app mounts checks to see if authorized to access so you don't have to login again
each time app mounts checks to see if authorized to access so you don ' t have to login again
componentDidMount() {
    this.setState({ loading: true });
    if (token) {
      console.log(token, "hello from CDM-token!");
      api.auth.getCurrentUser().then((user) => {
        this.setState({
          auth: {
            ...this.state.auth,
            user: { id: user.id, username: user.username },
            loggedIn: true,
          },
        });
        this.getUserData(user.id);
        this.getCategories();
        this.getFeelings();
        this.getAffirmation();
      });
    }
    this.setState({ loading: false });
  }
componentDidMount ( ) { this . setState ( { loading : true } ) ; if ( token ) { console . log ( token , "hello from CDM-token!" ) ; api . auth . getCurrentUser ( ) . then ( ( user ) => { this . setState ( { auth : { ... this . state . auth , user : { id : user . id , username : user . username } , loggedIn : true , } , } ) ; this . getUserData ( user . id ) ; this . getCategories ( ) ; this . getFeelings ( ) ; this . getAffirmation ( ) ; } ) ; } this . setState ( { loading : false } ) ; }
each time app mounts checks to see if authorized to access so you don't have to login again
each time app mounts checks to see if authorized to access so you don ' t have to login again
// console.log(this.state, 1);