Ajax getResponseHeader


#1

Hello to all,
I’m using F7 ver2 to do an Ajax call and I want to get the Response header.
In jquery I use getResponseHeader(‘token’). In F7 how I can do that?

Thank you


#2
var xhr = app.request.get('somepage.html');
xhr.getResponseHeader('token');

#3

Hello Vladimir,
I have the above code:

var xhr = app.request({ method: "POST", url: "THE_URL", data:"USERNAME/PASSWORD",success: function(data) {},error: function(xhr) {}
console.log(xhr.getResponseHeader('Token'));

In my browser Network response I can see the Token, but the console.log is null.

Am I doing something wrong?

Thank you


#4

I guess it should be done after request happened

var xhr = app.request({
  ...
  success: function(data, status, xhr) {
    console.log(xhr.getResponseHeader('Token'));
  }
})

#5

Thank you!!
It worked!!