'Why is an empty list being exported here? I want the appended list to be exported
const mongoose = require("mongoose");
const Post = require("/home/chibbaa/5chin/models/post.js");
const messageList = [];
Post.find()
.then((res)=>{
res.forEach((post)=>{
messageList.push(post);
}).then((res)=>{
module.exports = messageList;
})
/*console.log(messageList);
module.exports = messageList; */
})
const messageList = require('/home/chibbaa/5chin/static/messages.js');
router.get('/', (req,res) => {
res.render('home', {messageList});
})
Why does an empty list get passed on to the render function in the second piece of code?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
