I want to get datas from database (Mongodb) and write to EJS page.
My codes:
const express = require('express')
const router = express.Router()
const DroneSeries = require('../models/DroneSeries')
router.get('/technic-service', (req, res) => {
const droneSeries = DroneSeries.find((err, data) => {
if (err) {
console.log('Datas couldn\'t get ', err)
} else {
console.log(data)
}
})
console.log(droneSeries)
res.render('technic-service', { droneSeries: droneSeries })
})
console.log(data)
is works good. It gives me the data as I wanted (exp: all products). But if I write a code like console.log(droneSeries)
then it gives me many many informations but not datas as I want(exp: hosting informations, user informations, connection information... but there are no products informations...). That's why I can't get data from droneSeries variable. So I can't render my data in EJS. How to render my products to EJS?