eligrey / eligrey/FileSaver.js

saveAs not used. Throws server error on download

Open
#525 2 comments 0 reactions 0 assignees View on GitHub
help wanted Make a Blob
Dominant language
JavaScript
Stars
22k
Forks
4.3k
PR merge metrics
No merged PRs in 30d

Description

Not sure why I am getting a server error on download. I am working in React. The way I have this written it says, "saveAs is declared but not used. No unused vars" as a warning in the console. When I fire the click handler it attempts to download, but throws an error.

```js
import FileSaver, { saveAs } from 'file-saver'

handleClick = (event) => {
console.log("this.newOrder = ", this.newOrder)
const csv = Papa.unparse(this.newOrder)
console.log("csv = ", csv)
FileSaver.saveAs(csv)
}
```
```
_Uncaught TypeError: Cannot read property 'name' of undefined
at Function.a [as saveAs] (FileSaver.min.js:47)
at App._this.handleClick (App.js:85)
at Button.onClick (reactstrap.es.js:1115)
at HTMLUnknownElement.callCallback (react-dom.development.js:147) etc etc_
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.