I'm very new to node.js and async programming. I'm attempting to make a program that shuffles a spotify playlist. I put the user's playlists into an array.
I would like to display this array on the webpage for the user to select. Once the user makes their selection, I want to continue with the program using the selected element. This is the code snippet I've written thus far.
// Callback functions
function plCallback(selected_playlist) {
playlist_id =
console.log(playlist_id);
}
function getPlaylist(body, plCallback) {
// Pull user playlists
for (var i = 0; i < body.items.length; i++) {
playlistArray.push({'name': body.items[i].name, 'id': body.items[i].id});
}
// prompt user to select desired playlist to shuffle
var selPlaylist = document.getElementById('playlist-drop');
for (var i = 0; i < playlistArray.length; i++) {
var opt = playlistArray[i].name;
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
select.appendChild(el);
}
// send selected playlist to Callback
var dropdown_return = document.getElementById('playlist-drop');
var selected_playlist = dropdown_return.options[dropdown_return.selectedIndex].value;
plCallback(selected_playlist);
}
I am really at a loss for what I even need to search for since I'm so new to js and node.
To summarize: I populate a js array with spotify playlists. I want to display this list to the user to make a selection. Once that selection is made, I need the program to continue using said selection.