I'm very new to programming. I'm trying to make a project where a locally hosted website, would fetch titles of the songs from a youtube playlist and then adds them to a list. So far, it fetches the first 50 items/titles, but then the loop stops. What goes wrong here?
let tracks = [];
let token = "";
let items;
let items_total;
function execute() {
do {
return gapi.client.youtube.playlistItems.list({
"part": ["snippet"],
"maxResults": 50,
"pageToken": token,
"playlistId": "id of the playlist"
}).then(function(response) {
let playlist = response;
items = playlist.result.pageInfo.resultsPerPage;
items_total = playlist.result.pageInfo.totalResults;
token = playlist.result.nextPageToken;
for (let i = 0; i < items; i++) {tracks.push(playlist.result.items[i].snippet.title)}
},
function(err) { console.error("Execute error", err); });
} while (tracks.length < items_total)
}