curl → fetch
Turn a curl command into fetch code.
Turn a curl command into fetch code.
// Runs in your browser. Nothing you type here is sent anywhere.
A POST request with 2 headers.
As copied from a terminal, documentation or the Network tab of a browser ("Copy as cURL"), for bash or for the Windows command prompt.
{"customer":"ada@example.com","lines":[{"sku":"A-1","quantity":2}]}const response = await fetch('https://api.example.com/v1/orders?expand=lines', {
method: 'POST',
headers: {
Authorization: 'Bearer eyJhbGciOiJIUzI1NiJ9.e30.abc',
'Content-Type': 'application/json'
},
body: JSON.stringify({
customer: 'ada@example.com',
lines: [
{
sku: 'A-1',
quantity: 2
}
]
})
});
const data = await response.json();