There is a problem that if you quickly update the page, the script crashes, that is, the node falls, with the message:

TypeError: Cannot read property 'forEach' of undefined

I understand the script does not have time to receive data from the response, how to fix the problem?

function test(){ helf.send("clientlist", function(err, response){ response.forEach(function(response) { socket.emit('test123', { name: response.client_nickname, cid: response.cid }); }); }); } setInterval(function() { test() }, 1000 ); 

    1 answer 1

    No, you're wrong. When you call helf.send("clientlist", get an error, which you are notified of in the err parameter, and the response parameter remains empty. But since you do not check err it turned out what happened.