September 2017
Intermediate to advanced
450 pages
11h 24m
English
Reading headers in Express is done using the get or header method on a request object. You can also use req.headers to find a dictionary of all the headers passed along in the request:
req.get('user-agent');req.header('user-agent');req.headers['user-agent'];
Sending headers in Express is done by providing a header name and value to the set or header method of a response object. You can also set multiple headers at once by providing a dictionary. Some common response headers, such as Content-Type, also have aliases available on the response object:
res.set('Content-Type', 'text/html');res.set({ 'Content-Type': 'text/html', 'X-Frame-Options': 'SAMEORIGIN'});res.header('Content-Type', 'text/html');res.contentType('text/html' ...Read now
Unlock full access