Forms in JS

submitting forms in JS the most common and important task to do in javascript

const username = document.getElementById('username').value
const response = await fetch('https://myexampleapi.xyz/v1/todo/', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(data),
  });

add error handling and such.

React

nextjs typescript

the way we did it in genXC is the 2nd option (holding values in react state)

const [form, setForm] = useState({ email: '', password: '' });
const inputChange = (e: any) => setForm({ ...form, [e.target.id]: e.target.value });

//later on
<input id="email" type="email" required className="form-input" placeholder="Enter Email" onChange={inputChange} />