Closed milekz closed 2 years ago
fixed version
function getAllDroplets() {
var allDroplets = [];
function getDropletPage(page) {
if (page == null) {
page = 1;
}
return client.droplets.list(page)
.then(function(droplets) {
droplets.forEach(droplet => allDroplets.push(droplet));
var links = droplets._digitalOcean.body.links;
var isLastPage = links && (
!links.pages ||
(links.pages && links.pages.last === undefined)
);
if (isLastPage) {
return allDroplets;
} else {
return getDropletPage(page + 1);
}
});
}
return getDropletPage();
}
Thanks, would you be able to make a PR with this fix?
On Tue, May 3, 2022 at 8:24 AM Miłosz Szewczak @.***> wrote:
fixed version
` function getAllDroplets() { var allDroplets = [];
function getDropletPage(page) { if (page == null) { page = 1; }
return client.droplets.list(page) .then(function(droplets) { droplets.forEach(droplet => allDroplets.push(droplet)); var links = droplets._digitalOcean.body.links; var isLastPage = links && ( !links.pages || (links.pages && links.pages.last === undefined) );
if (isLastPage) { return allDroplets; } else { return getDropletPage(page + 1); }
});
}
return getDropletPage(); } `
— Reply to this email directly, view it on GitHub https://github.com/phillbaker/digitalocean-node/issues/38#issuecomment-1116038867, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAXCKORDXO2745ZGZIC57TVIELGRANCNFSM5U6WDPTQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
PR created
Hi,
I started to play with node+DO and found issue with one of examples from main doc.
Promise style
generate a bugTypeError: Cannot read properties of undefined (reading 'body')
-droplets
object don't have._digitalocean.body.links
data path