in

how to store user input value state from react to express js array and variable?


I am Junior React Developer and learning express js. My question is how can i pass user input value from react state to Express js Array & variable. What are the possible ways and which one is better?

React js Code

    import React, {useState} from "react";

function App() {

  const [textValue, settextValue] = useState("");
const [number, setnumber] = useState(10);
const [jsonresponse, setJsonresponse] = useState();
  

const  handleSubmit = async (e) => {
  e.preventDefault();
  
  console.log(textValue)
}

  return (
    <>
    <div className="container">
        <form onSubmit={handleSubmit}>
      <div class="my-3">
        <label forhtml="exampleInputEmail1" className="form-label">Text</label>
        <input type="text" class="form-control" onChange={(e) => settextValue(e.target.value)} id="exampleInputEmail1" aria-describedby="emailHelp" value={textValue} />
      </div>
        <div className="my-3">
      <input class="form-control"id="number" type="number" placeholder="Number" onChange={(e) => setnumber(e.target.value)} value={number}  /></div>
      <button type="submit" className="btn btn-primary">Submit</button>
    </form>
    </div>
    </>
  );}

Node js File index.js

const PAGE_SIZE = value from react userinput
const KEYWORDS = ['value from react userinput'];

2nd Question: After adding value into variables. An Api will be called and return json response. how can i can pass this JSON Response into react state



Source: https://stackoverflow.com/questions/70554563/how-to-store-user-input-value-state-from-react-to-express-js-array-and-variable

Apple Investigates Workers’ Living Conditions at Its Foxconn Manufacturing Facility

Perguidex — Organized task management and daily reviews