I was doing or making a function that will have a MYSQL result.
Now i'm making my self difficult to get those values inside the function
This is my code
var data = function () {
var expected;
db.query('Select Distinct REPLACE(title," ","-")title from antique_profile_definitions', function(err, antiqueProfile) {
expected= antiqueProfile;
});
return expected;
}
When I try to console.log(data)
it gives me [Function: data]
In normal using POST
it gives me a data which si correct
[
RowDataPacket { title: 'Land-Classification' },
RowDataPacket { title: 'Forest-Cover' }
]
Am i doing wrong already in the first place about my code?
Well I got it this will do the trick
data(function (expected){
db.query("Select * from antique_profile_definitions where title='" + replace + "'", function(err, result) {
response.render('Profile',{title:replace,definition:result,antiqueProfile:expected});
});
});