I do not know how to access the parameter x-error-detail-header.
I receive this response headers from a request using node-fetch npm package:
JavaScript
x
19
19
1
Headers {
2
[Symbol(map)]: {
3
'content-type': ['text/xml'],
4
date: ['Fri, 27 Apr 2018 09:46:56 GMT'],
5
'retry-after': ['51184'],
6
server: ['xxxxx'],
7
'x-error-detail-header': ['Account Over Rate Limit'],
8
'x-x-error-code': ['ERR_403_DEVELOPER_OVER_RATE'],
9
'x-x-responder': ['xxxxxxx.com'],
10
'x-plan-qps-allotted': ['2'],
11
'x-plan-qps-current': ['1'],
12
'x-plan-quota-allotted': ['50'],
13
'x-plan-quota-current': ['51'],
14
'x-plan-quota-reset': ['Saturday, April 28, 2018 12:00:00 AM GMT'],
15
'content-length': ['28'],
16
connection: ['Close']
17
}
18
}
19
My problem is that I do not know how to access the parameters that are inside [Symbol(map)] object.
Advertisement
Answer
It is a Headers object. It has e.g. get
and forEach
methods. For example:
JavaScript
1
9
1
getDownload = async (url) => {
2
const response = await fetch(url);
3
console.log(response.headers.get('content-type'));
4
return {
5
name: response.headers.get('Content-Disposition'),
6
length: response.headers.get('content-length')
7
}
8
}
9
Note the case insensitivity.