I have the following function which has a button and when clicking the button it triggers another function.
function navbar(id,CSVdata) {
if(CSVdata){
console.log('CSVdata',CSVdata)
return `<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a id="downloadcsv${id}" class="dropdown-item" href="#" onclick="downloadCSV(${id},${CSVdata})">Download CSV</a>
</div>
`;
}
}
function downloadCSV(id,data) {
console.log("downloadcsv",data);
}
The thing is when i console my CSVdata data it's showing correctly in the console. When i try to pass it to my downloadCSV function i'm getting an error as Uncaught SyntaxError:Unexpected identifier and the passed object is shown as downloadCSV(lc,[object Object]) What could be the issue here? I tried stringifying the object but still the same error.