const { MongoClient } = require('mongodb');
const client = new MongoClient('mongodb://localhost:27017/');
var arrayBrand;
exports.index = function(req, res) {
res.render('index');
(async function() {
await client.connect();
const cities = await client.db('iron_horse').collection('brand').distinct('name');
arrayBrand = cities;
console.log('Brand: ', arrayBrand);
arrayBrand.forEach(function(item, i, arrayBrand) {
var list = document.getElementById("brand_list")
var li = document.createElement('LI')
li.innerHTML = item
list.appendChild(li)
});
})().catch(console.error);
};
При попытке вывода массива в layout.jade выдает ошибку:
ReferenceError: document is not defined
at C:\Users\User\Desktop\iron-horse — копия\controllers\searchCarsController.js:16:18
at Array.forEach (<anonymous>)
at C:\Users\User\Desktop\iron-horse — копия\controllers\searchCarsController.js:15:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
GET /stylesheets/style.css 200 37.282 ms - 4665