How can I parse the data received from res.send() in an express router.post() method?

I have a HTML (React) form that has an action to be sent to an Express endpoint (’/login’). It’s a POST method, and in my Express file I have a router.post() method. Everything works smoothly as it’s supposed to, but I’m wondering how I can retrieve the data sent in the res.send() method, for example into this.state, and so that my already existing page isn’t replaced by a blank page. For now whenever I submit my form it turns my page completely white and blank except for the array that was sent in res.send() like so:

Here’s my code:

const express = require('express'); const router = express.Router(); const bodyParser = require('body-parser'); const connection = require('../MySQL') router.use(bodyParser.urlencoded({ extended: false })); router.use(express.json()) router.post('/', (req, res, next) => { const username = req.body.username; console.log(req.body) const password = req.body.password; connection.connect((err) => { connection.query(`SELECT * FROM Users WHERE username = '${username}' AND password = '${password}'`, (err, rows) => { if (err) { console.log("ERROR: ", err.message) res.status(404).send("Something went wrong. Can't query data.") } else { console.log(rows) const result = Object.values(JSON.parse(JSON.stringify(rows))) console.log(result) res.send(result) } } ) }) })

If you use the preventDefault() method on the submit event then that will stop the reloading of page. Also, if you are using React forms with Controlled Component technique then you will have variables for your form-entries that are updated. The useState hook is good for this but if you use class components you can also enter it into this.state instead. Personally, I really like functional components and the library react-hook-form to manage forms. But for basic usage check out this as it shows use of preventDefault and updating state:
https://reactjs.org/docs/forms.html