#Header sent problem

1 messages ยท Page 1 of 1 (latest)

small cosmos
#

Hi,

Handling endpoints in the node server and constantly getting
<Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client>

Error appears in the row having 200. I would think that this error shouldn't appear as I'm checking that header has not yet been sent..

else if (res.setHeader !== true) {
    res.status(200).json({ message: getLicenseResp });
  }

What I'm not getting ๐Ÿ™‚ ?

jolly leaf
#

What is res.setHeader !== true code checking? Should that be res.headersSent? And is there a reason that you'd want to check if the headers were already sent while in the route code anyway? I can't imagine a scenario where you would need to check that.

small cosmos
paper flint
small cosmos