About node Obtaining Results from Asynchronous Operations

  node.js, question
function getMusicName() {
 .then(function(connection) {
 var sql = 'select name from musicInfo';
 return queryMusicInfo(connection,sql);
 Because many functions in then are asynchronous.
 Is there any way to get the final result returned by then in the function getMusicName?  Or does promise have any mechanism to solve this problem?

To make a metaphor:
You go to the bank in 2016 to check how much money you have in your account, but the bank’s computing system is very slow, and it will take 2017 to find out. You don’t want to wait, so the bank assures you that it will inform you of the results.
Then your question now is whether you can ask the bank to tell yourself in 2016 when the results are found out in 2017.
The answer is obvious, no.


Oh, ha ha, I seem to have misunderstood what you mean. You can remove the second then and return this promise to the outside function.