Headers.getAll has been removed in favour of get now returning all values

Published: | Categories: DOM


The Headers.prototype.getAll method has been removed as per the latest Fetch spec. Instead, the Headers.prototype.get method now returns the all values of a given HTTP header in a comma-separated string instead of just the first value.

const headers = new Headers();
headers.append('Accept-Language', 'en');
headers.append('Accept-Language', 'fr');

// On Firefox 51 and prior
headers.get('Accept-Language'); // "en"
headers.getAll('Accept-Language'); // ["en", "fr"]

// On Firefox 52 and later
headers.get('Accept-Language'); // "en,fr"