1
I have a form in HTML
which should send data to a server in format JSON
. How I format this input data and send to a Rest API the JSON data the way I described below?
In my view I need to do a POST, the difficulty is to format the way it should be sent.
Form:
<form>
<div class="form-group">
<label for="nome">Nome</label>
<input type="text" class="form-control" id="nome" placeholder="Enter name">
</div>
<div class="form-group">
<label for="pw">Password</label>
<input type="password" class="form-control" id="pw" placeholder="Password">
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input">
Check me out
</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
The server should receive the data in JSON as follows
{
"nome": "Ricardo",
"pw": "01023423sdqz1",
}