I get the following error if a header has the value undefined:
iron-ajax.html:403 Uncaught TypeError: Cannot read property 'toString' of undefined
This is in the "get requestHeaders" method. Here is the relevant code:
if (this.headers instanceof Object) {
for (header in this.headers) {
headers[header] = this.headers[header].toString();
}
}
You might think no header should ever have the value undefined. However, this can happen when setting a header to the value of some other object property. For example,
header[name] = sessionStorage.something;
Here is the fix I suggest:
if (this.headers instanceof Object) {
for (header in this.headers) {
const value = this.headers[header];
if (value !== undefined) headers[header] = value.toString();
}
}
Steps to Reproduce
Set any iron-ajax header to undefined.
Expected Results
Handle this case.
Actual Results
iron-ajax.html:403 Uncaught TypeError: Cannot read property 'toString' of undefined
From @mvolkmann on September 28, 2016 15:20
Description
I get the following error if a header has the value undefined:
iron-ajax.html:403 Uncaught TypeError: Cannot read property 'toString' of undefined
This is in the "get requestHeaders" method. Here is the relevant code:
You might think no header should ever have the value undefined. However, this can happen when setting a header to the value of some other object property. For example,
Here is the fix I suggest:
Steps to Reproduce
Set any iron-ajax header to undefined.
Expected Results
Handle this case.
Actual Results
iron-ajax.html:403 Uncaught TypeError: Cannot read property 'toString' of undefined
Browsers Affected
all
Versions
probably all
Copied from original issue: Polymer/polymer#4012