I'm having trouble retrieving an object array from my MySQL database. Every time I run my code, I keep getting an "undefined" result and I can't figure out why.
database.query(sql, (err, rows)=>{
var data = Object.values(JSON.parse(JSON.stringify(rows)))
console.log(data[0].type)
})
When I console log the "data" variable, I see:
[
{
data: '[{"type": "c#", "script": "csharp script"}, {"type": "javascript", "script": "javascript script"}, {"type": "html", "script": "html script"}]'
}
]
This output seems correct to me, but I'm not sure how to proceed from here. Any assistance would be greatly appreciated