I have this function
offer.getReceivedItems(function(err, items) {
It returns an array (items) or throws an error err
if it failed.
Many times, when there isn't an err
, the items array is empty.
Like
[]
But when this array is empty, I need to try the same function again
offer.getReceivedItems(function(err, items) {
but how I can go back to it, when items is empty...
I tried so much, but I cannot find it...
Code looks like
offer.getReceivedItems(function(err, items) {
if (err) {
console.log("Couldn't get received items: " + err);
offer.decline();
} else {
console.log(items);
items.forEach(function(item,i,arr){
....
The forEach
doesn't run when there is an empty array...