How to get response headers from iron-form Polymer

Home / Uncategorized / How to get response headers from iron-form Polymer

Question:
I have a form, which I submit like so:form.addEventListener("iron-form-response", function(event) {
//How can I access response headers here?
});

form.submit();

I know the way I can access response body:event.detail.response

But what I want is server response headers. I need it, because this response may contain in headers some tokens, which I must store in cookies.


Answer:
The event.detail is actually an , which exposes the underlying XMLHTTPRequest via e.detail.xhr, which allows you to use getResponseHeader(name) for a specific header:_onResponse(e) {
const header = e.detail.xhr.getResponseHeader(‘X-Special-Header’);

}

Example:


demo
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *