GET request in JavaScript

In fact, to submit a form using the GET method, it isn't necessary to have a form. We can manually type the GET query parameters into the address bar and press Enter. This is how we simulate a form submission.

This technique is often used in website development. Of course, they don't manually type it into the address bar (although this is technically possible for advanced users), but create links that, when clicked, will simulate submitting a form.

Let's create a link like this:

<a href="/handler/?test1=1&test2=2">link</a>

We catch data from a link on the server:

export default { '/handler/': function({get}) { console.log(get); return 'text'; } }

Send a number to a server using the GET query parameter. Square the resulting number and output the result to the server console.

Send two numbers to a server using GET query parameters. Find the sum of the passed numbers and output the result to the server console.

enru