I'm trying to put each 'poetry' class's text into an array, however, the text ends up being an empty string. Does the each() function not work this way on classes?
(err, res, body) => {
if (err) return console.error(err);
let $ = cheerio.load(body);
let readings = [];
$('.poetry').each((i, e)=>{
readings[i] = $(this).text();
});
console.log(readings);
console.log($('.poetry').text());
})
The second console log prints a single string with the text of all of the poetry classes as expected, but I would like to split it up. Any help would be appreciated.