stackp / promisejs

Lightweight javascript implementation of promises.
443 stars 127 forks source link

How to access response headers #30

Closed se1exin closed 7 years ago

se1exin commented 7 years ago

Sorry if this has been answered but could not find by searching..

I need to access a custom response header (Date) in my ajax calls, how do I go about this?

se1exin commented 7 years ago

Figured it out: - use xhr.getResponseHeader('Date')

promise.get(this.path, params, {"Accept": "application/json"})
    .then(function(error, response, xhr) {
         var date = xhr.getResponseHeader('Date');
});
stackp commented 7 years ago

Indeed!