In Express.js, should I return response or not?

I do not agree with the answer above.
Sometimes the callback function can return several responses depending on the logic of the app:

router.post("/url", function(req, res) {
// (logic1)
     res.send(200, { response: 'response 1' });
   // (logic2) 
      res.send(200, { message: 'response 2' });
    }})  

This will throw this error:

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent
to the client

Which can actually be solved with using return. It can also be solved with using if else clauses.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)