My server.js file serves an array of objects that are created in a function called doScrape. I can console log them out (see code below), but the scrapedData takes a while to be created and I think this is why the res.send sends an object that is not intelligible. Do I need to somehow delay the res.send(scrapedData) command?
app.get('/dash/jobads', function(req, res, next){
var scrapedData = doScrape().then((value) => {
console.log(value);
});
res.send(scrapedData)
console.log('This is data from /dash/jobads:', scrapedData)
})
Thanks!