title: React button connection with database through axios.post()
body: <p>I have 4 inputs and button which takes all data from them and sends to my PostreSQL database through axios.post() request. Not clearly understand how .then() is working. So, here is my button code which just calls this.addNewPainting function:</p>
  
  <pre><code>&lt;button onClick={ this.addNewPainting }&gt;Submit&lt;/button&gt;
  </code></pre>
  
  <p>Here is my addNewPainting function:</p>
  
  <pre><code>addNewPainting() {
    axios.post(`http://localhost:333/api/add`, {
      title: this.state.titleInput,
      year: this.state.yearInput,
      size: this.state.yearInput,
      location: this.state.locationInput
    })
    .then(function(response) {
      console.log(response);
    })
    .catch(function (error) {
      console.log(error);
    });
  }
  </code></pre>
  
  <p>Before this project, I used to put response.data to the array with this.setState, but now I have the database and I'm just stuck.</p>
  
  <p>Here is my controller function:</p>
  
  <pre><code>add_painting: (req, res, next) =&gt; {
    const db = req.app.get('db');
    const { title, year, size, location } = req.body;
    console.log(title, year, size, location);
  
    db.add_painting([ title, year, size, location ])
      .then( () =&gt; res.status(200).send() )
      .then( () =&gt; res.status(500).send() );
  }
  </code></pre>
  
  <p>And the endpoint:</p>
  
  <pre><code>app.post('/api/add', paintings_controller.add_painting);
  </code></pre>