UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set Headers after they sent to the client
If you encounter this ...
For further actions, you may consider blocking this person and/or reporting abuse
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.
Thanks for the suggestion.