How to have an async endless loop with Promises
How can I achieve this?
Not with a blocking loop since promises won't be able to settle. You can learn more about JavaScript's event loop on MDN.
Instead, call the function again when the promise is resolved:
Promise.resolve().then(function resolver() {
return someAsyncFunction()
.then(doSomething)
.then(resolver);
}).catch((error) => {
console.log("Error: " + error);
});