July 2018
Intermediate to advanced
354 pages
8h 51m
English
The get method returns a specific headers value:
Var cacheHeader = myHeaders.get('Cache-Control');
//returns 'private, max-age=3600, s-max-age=300'
The entries method returns an iterator you can use to loop through all the headers. Each entry is a simple array, with the first entry being the header key name and the second member being the value:
// Display the key/value pairs
for (var header of myHeaders.entries()) {
console.log(header[0]+ ': '+ header[1]);
}
The keys method also provides an iterator, but only returns a list of header names:
// Display the keys
for(var key of myHeaders.keys()) {
console.log(key);
}
Conversely, you can get a list of values from the values method. The problem with this method is that ...
Read now
Unlock full access