Recursively calling asynchronous function that returns a promise
问题 I'm trying to recursively call AWS's SNS listEndpointsByPlatformApplication. This returns the first 100 endpoints then a token in NextToken if there are more to return (details: AWS SNS listEndpointsByPlatformApplication). Here's what I've tried: var getEndpoints = function(platformARN, token) { return new models.sequelize.Promise(function(resolve, reject) { var params = { PlatformApplicationArn: platformARNDev }; if (token != null) { params['NextToken'] = token; } sns