How to fetch response headers value in javascript?

Viewed 2286

I want to fetch the values of Response Header after getting the response from axios.

Server response

As you can see in the above image, I want to fetch the value of Location i.e. coming under the Response Header. Would you please help me. Thanks :)

1 Answers

As javascript abstracts the XMLHttpRequest object in a so-called "super set" that does not expose the responseURL field. If you are setting a custom header and want to use in your js file then you will need to set the Access-Control-Expose-Headers header with the custom header fields in server side and get in the client side by using getResponseHeader() function.

Related