yandex
loader

please wait

  • Ronak Singh Dec-17-2018 05:36:14 AM ( 3 months ago )

    I want to get user data after login on dashboard like username, email etc.how can i get it from login component to dashboard component in react js.

    I am using sessionStorage to save the user data and i want to get it on dashboard using session storage

     

    login component code as follow:

     

    // login function goes here

     login=()=>{

      if(this.state.email && this.state.password){

       PostData('login',this.state).then((result)=>{

        let responseJSON=result; 

        

        if(responseJSON){

         

          sessionStorage.setItem('userData',JSON.stringify(responseJSON));

          

          if(responseJSON.responseCode== 101) {  

            //console.log(responseJSON);

            this.setState({alert:'alert alert-danger'});

            this.setState({errorMsg:responseJSON.response});  

            this.setState({redirect:false});  

            }

            else if(responseJSON.responseCode==100){

              this.setState({redirect:true}); 

            }

        };

        

     

       })

Please login

Similar Discussion

Recommended For You