DEV Community

Discussion on: ERROR: Cannot set headers after they are sent to client!!!

Collapse
 
tqbit profile image
tq-bit • Edited

Or you could try and call res.json(data) after the loop (return may lead to undesired behaviour in this case).

This particular error is often caused whenever you try to send a second response after the first one.

Collapse
 
himanshupal0001 profile image
Himanshupal0001

Thanks for the suggestion.