Why did we pass an argument to xhr.send() for a POST request but not for GET?

Question

In the context of this exercise, why did we pass an argument to xhr.send() for a POST request, but not for a GET request?

Answer

If we recall the introduction text, a GET request is used to retrieve information from a source, while for a POST request, we “post” information to a source that processes the information and sends it back.

As a result, because a GET request is just for retrieving, we do not provide any argument to the xhr.send() method. However, for the POST request, we want to “post” the information, which is the JSON object in this exercise, by sending it through the xhr.send() method.

11 Likes