src/components/editProfile/EditProfile.js
// when the save changes button is clicked, the new data is sent to the server via put request
when the save changes button is clicked, the new data is sent to the server via put request
when the save changes button is clicked the new data is sent to the server via put request
async saveChanges() {
        try {
            const requestBody = JSON.stringify({
                name: this.state.name,
                username: this.state.username,
                password: this.state.password
            });
            const url = '/users/' + this.state.loggedInUserId;
            await api.put(url, requestBody);
            this.props.history.push('/userprofile');
        } catch (e) {
            this.handleErrorDesigned(e);
            this.setState({hasNoErrorMessage: false});
        }
    }
async saveChanges ( ) { try { const requestBody = JSON . stringify ( { name : this . state . name , username : this . state . username , password : this . state . password } ) ; const url = '/users/' + this . state . loggedInUserId ; await api . put ( url , requestBody ) ; this . props . history . push ( '/userprofile' ) ; } catch ( e ) { this . handleErrorDesigned ( e ) ; this . setState ( { hasNoErrorMessage : false } ) ; } }
when the save changes button is clicked, the new data is sent to the server via put request
when the save changes button is clicked the new data is sent to the server via put request
// after successfully saving the changes, the user is redirected to his profile page //alert(`Something went wrong while editing the profile: \n${handleError(e)}`);