If I understand your problem, you want to use the first button to get all the genres in the database and create a button for each genre, so :
1) Create a button with an onClick event that retrieves the genre field from your database as a JSON object.
Fetch API
2) With the query response, map the array, to create a array of buttons with the name of the genre as a title.
map function
3) In the previous loop, add an onClick event for each button to play your random songs.
The solution is in JS because you talk about Express.