Progressive Web Application Development by Example: Develop fast, reliable, and engaging user experiences for the web by Chris Love

Progressive Web Application Development by Example: Develop fast, reliable, and engaging user experiences for the web by Chris Love

Author:Chris Love [Love, Chris]
Language: eng
Format: epub, pdf
Tags: COM060090 - COMPUTERS / Internet / Application Development, COM060180 - COMPUTERS / Web / Web Services and APIs, COM051260 - COMPUTERS / Programming Languages / JavaScript
Publisher: Packt Publishing
Published: 2018-07-23T23:00:00+00:00


Accessing Header values

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 the values are not directly correlated to their keys:

// Display the values for (var value of myHeaders.values()) { console.log(value); }

You can check if a header exists by calling the has method:

myHeaders.has(name);

A header can be removed using the delete method:

myHeaders.delete(name);



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.