Answer the question
In order to leave comments, you need to log in
What is the best way to handle POST requests in Node.js?
Just starting to learn node.js.
I am creating a user login page. When filling out forms, I send his request to pages by type
router.post('/register',
userController.validateRegister,
userController.register,
authController.login
)
router.post('/login', authController.login);
Answer the question
In order to leave comments, you need to log in
Question. Is it possible to implement requests to the same page, and how can I check on the server side which request I am working with?
Can. But why?
IMHO after registration it is better to return 302 status and redirect to the login page. Or do the same on the frontend if SPA
router.post('/register', userController.validateRegister, userController.register, authController.login )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question