From Boilplate to "loop

Forgive me a maybe stupid question, at least for those who know, I don’t know.

I’m rather new to NodeJS.

I did some simple examples with this Boilerplate template:

If I want to work on a “list” of accounts/txs, yet I fail

(node:18866) UnhandledPromiseRejectionWarning: DisconnectedError: websocket was closed
at WebSocket. (/Users/michael/Downloads/XRPL/node_modules/ripple-lib/dist/npm/common/connection.js:360:48)
at Object.onceWrapper (events.js:422:26)
at WebSocket.emit (events.js:327:22)
at WebSocket.emitClose (/Users/michael/Downloads/XRPL/node_modules/ws/lib/websocket.js:198:10)
at TLSSocket.socketOnClose (/Users/michael/Downloads/XRPL/node_modules/ws/lib/websocket.js:886:15)
at TLSSocket.emit (events.js:327:22)
at net.js:674:12
at TCP.done (_tls_wrap.js:563:7)

something I would like to be able to do
api.connect().then(() => {
/* begin custom code ------------------------------------ */

genesisAccounts.forEach(account => {
    // sum up blances for these accounts


any help on this appreciated…

figured it out with Wietse Wind’s help…