onSubmit(e) {
    e.preventDefault();

    // When post request is sent to the create url, axios will add a new record to the database.
    const searchdata = {
      flight_from: this.state.flight_from,
      flight_to: this.state.flight_to,
      flightNum: this.state.flightNum,
      flight_date: this.state.flight_date,
      cabin: this.state.cabin,
      noSeats: this.state.noSeats,
      depTime: this.state.depTime,
      arrTime: this.state.arrTime,
      terminal: this.state.terminal,
    };

    axios
    .post("http://localhost:5000/search", searchdata)
    .then(() => console.log())
    .catch(err => {
      console.error(err);
    });  
    
    // axios
    //   .post("http://localhost:5000/search", searchdata)
    //   .then((res) => console.log(res.data));


    // We will empty the state
    this.setState({
      flight_from: "",
      flight_to: "",
      flightNum: "",
      flight_date: "",
      cabin: "",
      noSeats: "",
      depTime: "",
      arrTime: "",
      terminal: "",
    });

    this.setState({ redirect: "/searchrecord" });

  }
// This function will handle the submission.
This function will handle the submission.
This function will handle the submission .
onSubmit(e) {
    e.preventDefault();
    const searchdata = {
      flight_from: this.state.flight_from,
      flight_to: this.state.flight_to,
      flightNum: this.state.flightNum,
      flight_date: this.state.flight_date,
      cabin: this.state.cabin,
      noSeats: this.state.noSeats,
      depTime: this.state.depTime,
      arrTime: this.state.arrTime,
      terminal: this.state.terminal,
    };
    axios
    .post("http://localhost:5000/search", searchdata)
    .then(() => console.log())
    .catch(err => {
      console.error(err);
    });  
    this.setState({
      flight_from: "",
      flight_to: "",
      flightNum: "",
      flight_date: "",
      cabin: "",
      noSeats: "",
      depTime: "",
      arrTime: "",
      terminal: "",
    });
    this.setState({ redirect: "/searchrecord" });
  }
onSubmit ( e ) { e . preventDefault ( ) ; const searchdata = { flight_from : this . state . flight_from , flight_to : this . state . flight_to , flightNum : this . state . flightNum , flight_date : this . state . flight_date , cabin : this . state . cabin , noSeats : this . state . noSeats , depTime : this . state . depTime , arrTime : this . state . arrTime , terminal : this . state . terminal , } ; axios . post ( "http://localhost:5000/search" , searchdata ) . then ( ( ) => console . log ( ) ) . catch ( err => { console . error ( err ) ; } ) ; this . setState ( { flight_from : "" , flight_to : "" , flightNum : "" , flight_date : "" , cabin : "" , noSeats : "" , depTime : "" , arrTime : "" , terminal : "" , } ) ; this . setState ( { redirect : "/searchrecord" } ) ; }
This function will handle the submission.
This function will handle the submission .
// When post request is sent to the create url, axios will add a new record to the database. // axios //   .post("http://localhost:5000/search", searchdata) //   .then((res) => console.log(res.data)); // We will empty the state