The Fetch API is the modern browser standard for making network requests and interacting with RESTful APIs.
1The Request Flow
When you call fetch, the browser starts a network operation in the background and returns a Promise. Importantly, this promise resolves as soon as the server responds with headers—even before the actual data (the body) has finished downloading. This is why we have two distinct asynchronous steps: waiting for the response, and then waiting for the body to be parsed (e.g., into JSON).
2POST & Headers
Sending data requires more configuration than receiving it. You must specify the method as 'POST' and, crucially, set the 'Content-Type' header to 'application/json'. This tells the server how to interpret the text you are sending in the body. Without these headers, many servers will simply ignore the data you send or return an error.
