src/components/registration/Registration.js
/**
     * HTTP POST request is sent to the backend.
     * If the request is successful, a new user is returned to the front-end
     * and its token is stored in the localStorage.
     */
HTTP POST request is sent to the backend.
If the request is successful, a new user is returned to the front-end
and its token is stored in the localStorage.
HTTP POST request is sent to the backend . If the request is successful a new user is returned to the front - end and its token is stored in the localStorage .
async registration() {
        try {
            const requestBody = JSON.stringify({
                username: this.state.username,
                name: this.state.name,
                password: this.state.password
            });
            const response = await api.post('/users', requestBody);
            new User(response.data);
            this.props.history.push(`/login`);
        } catch (error) {
            this.handleErrorDesigned(error);
            this.setState({hasNoErrorMessage: false});
        }
    }
async registration ( ) { try { const requestBody = JSON . stringify ( { username : this . state . username , name : this . state . name , password : this . state . password } ) ; const response = await api . post ( '/users' , requestBody ) ; new User ( response . data ) ; this . props . history . push ( ` ` ) ; } catch ( error ) { this . handleErrorDesigned ( error ) ; this . setState ( { hasNoErrorMessage : false } ) ; } }
HTTP POST request is sent to the backend.
HTTP POST request is sent to the backend .
// Get the returned user and update a new object. // Registration successfully worked --> navigate to the route /login in the AppRouter