ReactJS displays MySQL seletion query result

Hey guys. I want to display my query result on my page AFTER I click submit button of a form. image
My backend works as I tested with POSTMAN.

//selection'/select', multerParse.none(),(req,res)=>{
    let sql = 'SELECT * FROM users WHERE username = ?'
    db.query(sql, [req.body.username], (err,result)=>{
        if(err) throw err;

But something wrong with my frontend.

handleSelection = event =>{
  const data = new FormData(
    method: 'POST',
    body: data

I guess it might be that once I click submit, the page refreshes and my state changes back. Is there a way to display my query result after I click?
I used a third-party Component called JsonToTable to quickly render tables.

<form onSubmit={this.handleSelection} >
      <h2>Select User</h2>
      <input name='username' placeholder='Please enter username' type='text'/>
      <JsonToTable json={}/>

Thank you

You have a couple of issues.

  1. You are not returning anything from the backend. You should not be getting any of the data back when using Postman. In Postman, you would click on the Body tab of the Response section to see what is getting returned.

  2. You need to disable the default action when the button is clicked and I would recommend using an onClick event on the button instead of an onSubmit event for the form.

  3. You will need another .then before the one that does the setState, because you need to convert the response to JSON. See this challenge for more information about using fetch.