When I try to clean the result of my query and output it in console it returns "undefined" for both the value tag and the options content. I know I am using the correct column names for this. I am using the nodejs mssql package for this. Any idea on why this is happening and how to fix it?
querymodule
const query = () =>{
var output =``
sql.connect(config).then(pool => {
// Query
return pool.request()
.query('SELECT Pdf_Filename, SKU FROM RDCProductLabels WHERE PDF_Filename is not null Order by SKU')
}).then(result => {
for(data in result){
output +=`
<option value="${data.PDF_Filename}">
${data.SKU}
</option>
`
}
console.log(output)
}).catch(err => {
console.log(`an error occurred - ${err}`)
});
}
generated html
<option value="undefined">
undefined
</option>
<option value="undefined">
undefined
</option>
<option value="undefined">
undefined
</option>
<option value="undefined">
undefined
</option>
<option value="undefined">
undefined
</option>