{"size": 1349, "ext": "js", "max_stars_repo_path": "react-keycloak/src/UserInfo.js", "max_stars_repo_name": "jurelmartin/keycloak-demo2", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "react-keycloak/src/UserInfo.js", "max_issues_repo_name": "jurelmartin/keycloak-demo2", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "react-keycloak/src/UserInfo.js", "max_forks_repo_name": "jurelmartin/keycloak-demo2", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.1041666667, "max_line_length": 89, "alphanum_fraction": 0.4633061527}
import React, { Component } from 'react';

class UserInfo extends Component {

    constructor(props) {
        super(props);
        this.state = {
            name: "",
            email: "",
            id: ""
        };
        console.log(this.props.keycloak.token)
        this.props.keycloak.loadUserInfo().then(userInfo => {
            this.setState({name: userInfo.name, email: userInfo.email, id: userInfo.sub})
        });
    }
    // async componentDidMount(){
    //     const url = "http://localhost:8080/products";
    //     const response = await fetch(url, {
    //         headers: {
    //             Authorization: `Bearer ${this.props.keycloak.token}`
    //         } 
    //     });
    //     const data = await response.json();
    //     console.log(data)

    // }


    render() {
        return (
            <div className="account">
                <h3>Account</h3>
                <div className="details-row">
                    <label>Name: {this.state.name} </label>
                </div>
                <div className="details-row">
                    <label>Email: {this.state.email} </label>
                </div>
                <div className="details-row">
                    <label>ID: {this.state.id} </label>
                </div>

            </div>
        );
    }
}
export default UserInfo;