I have code that passes data through a react component from a form to a backend. The backend processes it and sends a response. However I am confused with the const keyword, I am seeing in the code.
axios{
  .post('/api/users/register', newUser)
  .then(res => console.log(res.data))
  .catch(err => this.setState({ errors: err.response.data }));
}
render() {
    const { errors } = this.state;
     <div className="form-group">
              <input
                type="text"
                className={classnames('form-control form-control-lg', {
                  'is-invalid': errors.name
                })}
                placeholder="Name"
                name="name"
                value={this.state.name}
                onChange={this.onChange}
      />
You can assume that the code works. However, why is const {errors} defined like this, and how come it can access the errors list from the backend is-invalid': errors.name.
Thank you.
 
     
    