var songs = [];
request.get(getSongs, function(error, response, body){
append(songs,body);
});
function append(arr, data){
for (let j = 0; j < data.items.length; j++) {
console.log(data.items[j].track.name);
arr.push(songs,data.items[j].track.name);
}
}
console.log(songs); //outputs '[]'
I've google a lot and I'm not sure what I'm doing wrong.
For some context, request.get() returns between 1 and 20 objects, and I'd like to add an attribute (or more) of all of them to the array 'songs'. They console.log() correctly and their positions are correct, but when I log the array, it appears to be empty.
What am I doing wrong? Thanks for the help.