I'm a noob to react and I'm trying to make a post request and display the responses.This is my search component where I make a post request
import React, { Component } from 'react';
import {FormGroup, ControlLabel, FormControl, HelpBlock, Button} from 'react-bootstrap';
import {fieldset} from 'purecss/build/pure.css';
import './layout.css';
import axios from 'axios';
export class Search extends React.Component{
state = {
Movie :'',
}
handleChange = event =>{
this.setState({Movie: event.target.value});
}
handleSubmit = event =>{
event.preventDefault();
const movie_name = {
Movie: this.state.Movie
};
axios.post(`http://127.0.0.1:7002/get-suggestions`,{movie_name})
.then(res =>{
console.log(res);
console.log(res.data);
})
};
render(){
return(
<div id='layout'>
<div className="pure-g">
<div className="pure-u-12-24">
<form className="pure-form" onSubmit={this.handleSubmit}>
<fieldset>
<legend >Enter Movie Name</legend>
<input type="text" placeholder="Movie" onChange={this.handleChange}/>
<button type="submit" class="pure-button pure-button-primary">Suggest</button>
</fieldset>
</form>
</div>
</div>
</div>
);
}}
I'm able make a post request sucessfully but not able to get the response to display can anyone explain me why the response is not being console.logged and the response is a list