I'm new in lwc.
I was supposed to export function and import it as a module in lwc,
but when i deploy the JS file which has export function it shows i didn't return a value.
I really don't know which value i should return. Could you please help me?
Here is my utils.js
export function exportCSVFile(headers, totalData, fileTitle){
if(!totalData || !totalData.length) {
return null
}
const jsonObject = JSON.stringify(totalData)
const result = convertToCSV(jsonObject, headers)
if(!result){
return null
}
const blob = new Blob([result])
const exportedFileName = fileTitle? fileTitle+ '.csv': 'export.csv'
if(navigator.msSaveBlob){
navigator.msSaveBlob(blob, exportedFileName)
} else if(navigator.userAgent.match(/iPhone|iPad|iPod/i)){
const link = window.document.createElement('a')
link.href = 'data:text/csv;charset=utf-8,' + encodeURI(result);
link.target = "_blank"
link.download = exportedFileName
link.click()
} else {
const link = window.document.createElement('a')
if(link.download !== undefined){
const url = URL.createObjectURL(blob)
link.setAttribute("href", url)
link.setAttribute("download", exportedFileName)
link.style.visibility="hidden"
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
}
}
function convertToCSV(objArray, headers){
...
return str
}