No body
Sometimes there is nothing to send
We have spent two lessons talking about body formats: JSON, form data, multipart. But many HTTP messages have no body at all. Understanding when and why helps you design better APIs and avoid confusing bugs.
Requests without bodies
Some HTTP methods do not send a body.
GET reads data. The server knows what to return from the URL and headers alone. No body needed.
GET /books?genre=fiction HTTP/1.1
Host: api.example.com
Accept: application/json All the information is in the URL (/books), the query string (genre=fiction), and the headers (Accept: application/json). What if you tried to add a body to a GET request anyway? Technically, HTTP does not forbid it. But the spec says a GET body has “no defined semantics,” which is a polite way of saying nobody has to read it. Many servers, proxies, and CDNs ignore or strip the body from GET requests entirely. Your data might be silently thrown away. Use query parameters instead.
DELETE removes a resource identified by the URL. The URL already says what to delete.
DELETE /books/book-1 HTTP/1.1
Host: api.example.com
Authorization: Bearer tok_123 HEAD is identical to GET but the server explicitly omits the response body. The client only wants the headers.
OPTIONS asks what is allowed. No body sent, and usually no body returned.
Responses without bodies
Some responses have no body either.
204 No Content means the action succeeded but there is nothing to return. This is the typical response after a DELETE.
HTTP/1.1 204 No Content No Content-Type header. No Content-Length header. No body. The status code alone tells the client everything it needs to know.
304 Not Modified means the resource has not changed since the client last fetched it. The client should use its cached copy. No body is sent.
1xx and some 3xx responses also have no body.
The difference between “no body” and “empty body”
This is subtle but worth knowing:
HTTP/1.1 200 OK
Content-Length: 0 This says “the body exists and has 0 bytes.” The response has a body. It is just empty.
HTTP/1.1 204 No Content This says “there is no body at all.” No Content-Length, no body.
In practice, this distinction rarely matters. But it explains why some tools behave differently with 204 (no body) versus 200 with an empty body.
A common mistake: parsing a 204 response
What happens if a client calls response.json() on a 204 response? It throws an error. There is no body to parse. This is a bug you will run into if you do not check the status code first.
const response = await fetch(url, { method: "DELETE" });
if (response.status === 204) {
console.log("Deleted successfully");
} else {
const data = await response.json();
console.log(data);
} Always check the status code before trying to read the body. Not every successful response has one.
That wraps up the body section. We have covered JSON, form data, multipart, and the cases where there is no body at all. The next section goes beneath HTTP itself: the connection layer. What happens before HTTP even starts? DNS lookups, TCP handshakes, and TLS encryption.
Exercises
Exercise 1: Make a DELETE request. Verify the response is 204 with no body.
Exercise 2: Try calling response.json() on a 204 response. Observe the error.
Exercise 3: Make a HEAD request. Verify the response has headers but no body.
Why should you not send a body with a GET request?