# Download a CSV document

**URL:** <https://forum.wixstudio.com/t/download-a-csv-document/62261>\
**Category:** Ask the community\
**Tags:** code, question, wix\
**Created:** [August 28, 2024, 3:19am UTC](https://forum.wixstudio.com/t/download-a-csv-document/62261 "2024-08-28T03:19:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![karibuu-co](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/karibuu-co/32/27447_2.png) [@karibuu-co](https://forum.wixstudio.com/u/karibuu-co)\
**Post date:** [August 28, 2024, 3:19am UTC](https://forum.wixstudio.com/t/download-a-csv-document/62261/1 "2024-08-28T03:19:41Z")

</div>

**Question:**  
How to download automatically a csv file into users navigator?

**Product:**  
Wix Editor

**What are you trying to achieve:**  
The idea is that the user click on a bottom that allows to download de csv file of a dataset! I already have my back end function on my own server that manages the data of dataset and retrieves a HTTPS response

I’m only been able to make it “downloadble” the document on users console

**What have you already tried:**

```javascript
function downloadUsers() {
  const token = local.getItem('token');

  fetch("https://example.com/example", {
    method: 'GET',
    headers: {
      'Authorization': `Bearer ${token}`
    }
  })
  .then((httpResponse) => {
    if (httpResponse.ok) {
      return httpResponse.blob();Blob
    } else {
      return Promise.reject("Hubo un problema con la descarga.");
    }
  })
  .then(blob => {
    
    const reader = new FileReader();
    reader.readAsDataURL(blob);
    reader.onloadend = () => {
      const base64Data = reader.result; // data:text/csv;base64,...
      console.log(base64Data)
    };
  })
  .catch(error => {
    console.error('Error al descargar el archivo:', error);
  });
}

```

**Additional information:**  
Thanks!

---

<div class="post-metadata">

**Author:** ![thomasj](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/thomasj/32/30791_2.png) [@thomasj](https://forum.wixstudio.com/u/thomasj)\
**Post date:** [August 28, 2024, 1:54pm UTC](https://forum.wixstudio.com/t/download-a-csv-document/62261/2 "2024-08-28T13:54:10Z")

</div>

If your backend function returns a external URL with the CSV Document, you can use the [wixLocationFrontend.to()](https://dev.wix.com/docs/velo/api-reference/wix-location-frontend/to) method to allow users to download the file locally.
