Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With iron-ajax, how to read the headers of a response?

When a response for a request arrives, is there any way to read the response headers?

like image 245
Allan Hasegawa Avatar asked Jun 12 '15 05:06

Allan Hasegawa


1 Answers

The response event handlers gets passed the <iron-request> as the second argument. <iron-request> has an xhr property that is the XMLHttpRequest used to make the request. You should be able to get the response headers from that.

<iron-ajax on-response="ajaxResponse"></iron-ajax>
...
ajaxResponse: function(e, request) {
  var headers = request.xhr.getAllResponseHeaders();
}
like image 177
Trevor Dixon Avatar answered Sep 19 '22 00:09

Trevor Dixon