HTTP request headers via AJAX in JavaScript
Using the headers
setting, you
can send HTTP request headers:
button.addEventListener('click', function() {
let promise = fetch('/handler/', {
headers: {
name1: 'value1',
name2: 'value2',
}
});
});
Pass the Content-Type
header
to a server with the text/plain
value.
Study the list of forbidden request headers.