Curl to Code
DeveloperConvert curl commands to JS, Python, Go
curl command
POSThttps://api.example.com/v1/users2 headersjson body
Code
const response = await fetch("https://api.example.com/v1/users", {
method: "POST",
headers: {
"Authorization": "Bearer <token>",
"Content-Type": "application/json",
},
body: JSON.stringify({
"name": "Ada",
"role": "admin"
}),
});
const data = await response.json();
console.log(data);