I'm uploading a file using Papa Parse and having trouble assigning the let data
variable within complete. The data
variable returns undefined. Can someone please explain what I'm doing wrong here?
handleCSVInputChange(event) {
event.preventDefault();
let data;
const file = event.target.files[0];
Papa.parse(file, {
header: true,
complete: function(results, file) {
if (results) {
data = results.data;
}
}
})
if (data) {
console.log('p', data);
}
}