Forge
/ local toolbox
Home
Search
Home
Developer
cURL → fetch
cURL → fetch
Convert cURL to JS fetch.
curl -X POST https://api.example.com/x -H "Content-Type: application/json" -d '{"a":1}'
fetch("https://api.example.com/x", { "method": "POST", "headers": { "Content-Type": "application/json" }, "body": "{\"a\":1}" }) .then(r => r.json()) .then(console.log);
Copy