We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

POST Requests

An HTTP POST request sends data to a server, typically to create a new resource.

Adding a Body

The body of the request is the payload sent to the server. The special Content-Type header is used to tell the server the format of the body: application/json for JSON data in our case. POST requests are generally not safe methods to call multiple times because that would create duplicate records. For example, you wouldn't want to accidentally send a tweet twice.

await fetch(url, {
  method: "POST",
  mode: "cors",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
});

Assignment

We need to save newly created users on our Jello server. We will use the getUsers function we created in the last exercise to make sure our creation logic is working.

Let's create the createUser() function. It should: