title: Unhandled Rejection (TypeError): Cannot read property 'push' of undefined aftering trying to do POST request
body: <p>This error pops up in browser when trying to post: 
  newest error:</p>
  
  <p>TypeError: Cannot read property 'push' of undefined
      at SandwhichForm.js:30
      at async SandwhichForm.handleFormSubmit (SandwhichForm.js:27)</p>
  
  <p>Here is the full code:</p>
  
  <pre><code>
      import React from 'react';
      import { Form, Input, Button } from 'antd';
      import { connect } from "react-redux";
      import axios from 'axios';
  
      const FormItem = Form.Item;
  
  
      class SandwhichForm extends React.Component {
  
          handleFormSubmit = async (event, requestType, sandwhichID) =&gt; {
              event.preventDefault();
  
              const postObj = {
                  title: event.target.elements.title.value,
                  content: event.target.elements.content.value
              }   
  
          axios.defaults.xsrfHeaderName = "X-CSRFTOKEN";
          axios.defaults.xsrfCookieName = "csrftoken";
          axios.defaults.headers = {
              "Content-Type": "application/json",
              Authorization: `Token ${this.props.token}`,
          };
  
          if (requestType === "post") {
              await axios.post('http://127.0.0.1:8000/api_sandwhiches/create/', postObj)
                  .then(res =&gt; {
                      if (res.status === 201) {
                          this.props.history.push(`/`);
                      }
                  })
                  .catch(error =&gt; console.error(error));
          } else if (requestType === "put") {
              await axios.put(`http://127.0.0.1:8000/api_sandwhiches/${sandwhichID}/update/`, postObj)
                  .then(res =&gt; {
                      if (res.status === 200) {
                          this.props.history.push(`/`);
                      }
                  })
                  .catch(error =&gt; console.error(error));
              }
          };
  
          render() {
              return (
                  &lt;div&gt;
                      &lt;Form 
                          onSubmit={event =&gt; 
                              this.handleFormSubmit(
                                  event,
                                  this.props.requestType,
                                  this.props.sandwhichID
                              )
                          }
                      &gt;
                          &lt;FormItem label="Title"&gt;
                              &lt;Input name = "title" placeholder="Put a title here" /&gt;
                          &lt;/FormItem&gt;
                          &lt;FormItem label="Content"&gt;
                              &lt;Input name="content" placeholder="Enter some content ..." /&gt;
                          &lt;/FormItem&gt;
                          &lt;FormItem &gt;
                              &lt;Button type="primary" htmlType="submit"&gt;
                                  {this.props.btnText}
                              &lt;/Button&gt;
                          &lt;/FormItem&gt;
                      &lt;/Form&gt;
                  &lt;/div&gt;
              );
          }
      }
  
      const mapStateToProps = state =&gt; {
          return {
              token: state.token
          };
      };
  
      export default connect(mapStateToProps)(SandwhichForm)
  
  </code></pre>
  
  <p>What is happening:</p>
  
  <ol>
  <li>Information was posting and going to api</li>
  <li>error now in console not browser</li>
  <li>info is no longer posting</li>
  </ol>