execute promises recursively nodejs
问题 the following function creates new folder on my server via xmlrpc var createFolder = function(folder_name) { var defer = Q.defer(); client.methodCall('create_folder', [sessionID, folder_name], function(err, resp) { if (err) { if (err.responseString && err.responseString.match('already exist')) { //call the same function recursively with folder_name+Math.round(Math.random()*100) } else { defer.reject(err); } } else { defer.resolve(folder_name); } }); return defer.promise; } The functions