eligrey/FileSaver.js

saveAs not used. Throws server error on download

Open

#525 opened on Feb 14, 2019

View on GitHub
 (2 comments) (0 reactions) (0 assignees)JavaScript (21,193 stars) (4,366 forks)batch import
Make a Blobhelp wanted

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.

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