Я возвращал пуш, и не правильно экспортировал.
const getSongsObject = async () => {
for (let i = 0; i < names.length; i++) {
try {
const metadata = await mm.parseFile(`${__dirname}\\${names[i]}`);
let picture = metadata.common.picture[0];
let encodedPicture = `data:${picture.format};base64,${picture.data.toString('base64')}`;
let trackDuration = metadata.format.duration;
let trackTitle = metadata.common.title;
let trackArtist = metadata.common.artist;
let id = Date.now();
let trackObj = { id, trackTitle, trackArtist, trackDuration, encodedPicture }
songsObjectArray.push(trackObj);
} catch (error) {
console.error(error.message);
}
} return songsObjectArray;
}
module.exports = {
getSongsObject
}
// main
const dp = require('../music/dataParser')
dp.getSongsObject().then((result) => {console.log(result)})