How do I include a form parameter in a POST request using JavaScript fetch()? For example:
curl --form "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3a5b4c5b4e5a5840787a51454b585d">[email protected]</a>" "https://example.com/api/v4/endpoint"
I attempted the following code:
const form = new FormData()
form.append("foo":"bar")
fetch( "https://someapi.org/api", {
method: 'POST',
headers: form
} )
.then( response => response.json() )
.then( response => {
console.log(response)
} );
}
This approach did not work for me.