I am using hbs as view in frontend. I tried to send data to my script in html from nodejs like this :
router.get('/home',authController.isLoggedIn, (req ,res) => {
if(req.user){
    db.query('SELECT * FROM posts ORDER BY id desc ', (error,results) => {
        if (error) {
            console.log(error);
        } else {
            let categories;
            db.query('SELECT * FROM categories', (error,result) => {
                if (error) {
                    console.log(error);
                } else {
                    console.log(result);
                    categories = result;
                    return res.render('home',{
                        results: results,
                        categories: categories
                    });
                }
            });
        }
    });
}else {
    res.redirect('/login');
}
});
then when i am trying to call it here in script using javaScript it tells me something is wrong
<script>
        alert(results);
 </script>
I want to know how correctly call the the object in script
edit:
the data should be something like this :
  [
  RowDataPacket { id: 1, category: 'Music' },
  RowDataPacket { id: 2, category: 'Memes' },
  RowDataPacket { id: 3, category: 'Tech' }
  ]
 
    