I have a React JS application where I send a GET request with axios. In the browser, in the Response Headers section, when I send the request I get Content-Disposition: attachment;filename="image123.pdf", but when I try to get this in React, I don't get any field with this name. So when I try to access the response.headers['content-disposition'], I don't get anything.
Is it possible to read this header key using React JS using axios?
You must ensure that appropriate access has been granted from the server side for this matter through CORS. You can perform a quick comparison with the following piece of code to make sure that there is no issue for server-side access to this specific matter. check it in server:
res.header('Access-Control-Expose-Headers', 'Content-Disposition');
The next step for you is to make sure that you are sending these two items from the client side to the server.
set in header (client-side):
responseType: 'blob',
withCredentials: true,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With