Created
March 18, 2019 13:01
-
-
Save Mulperi/7b693667a77280a00c061b71c998df7d to your computer and use it in GitHub Desktop.
JSON Array to CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { saveAs } from "file-saver"; | |
import * as converter from "json-2-csv"; | |
converter.json2csv(this.items, (err, csv) => { | |
if (!err) { | |
const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" }); | |
saveAs(blob, "export.csv"); | |
} else { | |
console.log("Error converting data to CSV."); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment