src/components/profile/Settings.js
/**
     * componentDidMount() is invoked immediately after a component is mounted (inserted into the tree).
     * Initialization that requires DOM nodes should go here.
     * If you need to load data from a remote endpoint, this is a good place to instantiate the network request.
     * You may call setState() immediately in componentDidMount().
     * It will trigger an extra rendering, but it will happen before the browser updates the screen.
     */
componentDidMount() is invoked immediately after a component is mounted (inserted into the tree).
Initialization that requires DOM nodes should go here.
If you need to load data from a remote endpoint, this is a good place to instantiate the network request.
You may call setState() immediately in componentDidMount().
It will trigger an extra rendering, but it will happen before the browser updates the screen.
componentDidMount () is invoked immediately after a component is mounted ( inserted into the tree ) . Initialization that requires DOM nodes should go here . If you need to load data from a remote endpoint this is a good place to instantiate the network request . You may call setState () immediately in componentDidMount () . It will trigger an extra rendering but it will happen before the browser updates the screen .
componentDidMount() {
        var cat = localStorage.getItem('userId');
        console.log("ID from local storage: "+ cat);
        let path = `${getDomain()}/users/` + localStorage.getItem("userId");
        const status = response =>{
            if(response.status === 200){
                return Promise.resolve(response);
            }
            return Promise.reject("not receiving status 200");
        };
        const json = response => response.json();
        fetch(path, {
            method: "GET",
            headers: {
                "Content-Type": "application/json",
                "token": localStorage.getItem("token")
            }
        })
            .then(status)
            .then(json)
            .then(data =>{
                this.setState({user: data});
                this.setState({userid: this.state.user.id});
                this.setState({username: this.state.user.username});
                this.setState({birthday:this.state.user.birthday});
            })
            .catch(err =>{
                console.log('Error', err);
            })
    }
componentDidMount ( ) { var cat = localStorage . getItem ( 'userId' ) ; console . log ( "ID from local storage: " + cat ) ; let path = ` ${ getDomain ( ) } ` + localStorage . getItem ( "userId" ) ; const status = response => { if ( response . status === 200 ) { return Promise . resolve ( response ) ; } return Promise . reject ( "not receiving status 200" ) ; } ; const json = response => response . json ( ) ; fetch ( path , { method : "GET" , headers : { "Content-Type" : "application/json" , "token" : localStorage . getItem ( "token" ) } } ) . then ( status ) . then ( json ) . then ( data => { this . setState ( { user : data } ) ; this . setState ( { userid : this . state . user . id } ) ; this . setState ( { username : this . state . user . username } ) ; this . setState ( { birthday : this . state . user . birthday } ) ; } ) . catch ( err => { console . log ( 'Error' , err ) ; } ) }
componentDidMount() is invoked immediately after a component is mounted (inserted into the tree).
componentDidMount () is invoked immediately after a component is mounted ( inserted into the tree ) .
//DEBUGGING //build api path with id from local storage