I want to create simple react component with form inside, every time that user click Submit button, data should be send to the server.
For testing purposes I created component with two buttons, one stand alone and one inside form.
return (
    <>
    <button onClick={submit}>Working example</button>
    <form style={cellStyle}
        onSubmit={submit}>
                
        <div>
            <input type="submit"
                value={reactDict["send"]}
                className="btn btn-success"
                style={{ margin: "15px 5px 5px 0px" }} />
        </div>
    </form>
    </>
);

Both of them use same "submit" function
const submit = (event) => {
    event.preventDefault();
    const requestOptions = {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ test: 'some message' })
    };

    fetch(`neededitems`, requestOptions)
        .then(async response => {
            console.log(response);
        })
        .catch(error => {
            console.error('There was an error!', error);
        });
}

When I click button outside form everything works fine ,
When I click submit button inside form I got an error .

Why I can't send data using submit button inside Form
Add the attribute method="post" to the  element.
