0

First of all, I want to say that I'm a beginner and am trying to solve a task involving downloading an Excel file from the backend in a project. Front-end : React & Redux & Rtk Query Back-end: Java & Spring

The problem I'm facing is that I can't use RKT Query to download the file because of caching. Therefore, I have decided to retrieve the file using the Fetch API.

However, I'm struggling with the fact that the name of the file should be delivered from the backend, and as I understand it, this requires the Content-disposition header to be present. When I make a simple fetch request and check the Network tab in the dev tools, I can see the Content-disposition header. But when I try to log the response in the code, the Content-disposition seems to be missing.

The code is simply a fetch API method.

This is the first time I need to get a name from the backend, and to be honest, I have no clue what I'm doing wrong.

I have included an image of the Response Headers from the dev tools, along with what the console.log output looks like.

enter image description here

That is the response from fetch API enter image description here

Mati
  • 31
  • 4
  • Is it possible that the Fetch API and Cors 'disable' some headers? – Mati May 05 '23 at 14:13
  • Does this answer your question? [How to get the filename from a file downloaded using Javascript Fetch API?](https://stackoverflow.com/questions/49286221/how-to-get-the-filename-from-a-file-downloaded-using-javascript-fetch-api) – Heretic Monkey May 05 '23 at 14:18
  • @HereticMonkey ahh you have totally right, my bad I gonna remove the image and provide more text information. – Mati May 05 '23 at 14:24

0 Answers0