It is often not very convenient to manually
form a Query String. It is more handy to do
this through
URLSearchParams
:
button.addEventListener('click', function() {
let searchParams = new URLSearchParams();
searchParams.set('num1', '1');
searchParams.set('num2', '2');
let promise = fetch('/handler/', {
method: 'post',
body: searchParams,
});
});
The client has a div, a button, and three inputs. Numbers are entered into the inputs. By clicking the button send the entered numbers to a server. Let the server find the sum of sent numbers and return it back. Write result in the div.