I have a form in HTML
that should send data to a server in JSON
format. How do I format this input and submit data to an API Rest the data in JSON in the way I described below?
As I see it, 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",
}