cURL to Code Converter

curl command
POSThttps://api.example.com/v1/users2 headers
fetch("https://api.example.com/v1/users", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    "name": "Ada Lovelace",
    "role": "Engineer"
  })
})
  .then((res) => res.json())
  .then((data) => console.log(data))
  .catch((err) => console.error(err));