[SOLVED] I am getting error "POST http://localhost:3001/auth/login 400 (Bad Request)"

Issue

I am new to node js and am developing a simple website. when sending an unregistered username to the server, instead of getting the "username/password does not exist", I am getting "POST http://localhost:3001/auth/login 400 (Bad Request)". can someone plz help me figure out this problem? thank you.

my middleware

enter image description here

my Post request

enter image description here

my route

const router = require("express").Router();
const {loginUser, registerUser} = 
require("../controllers/authController.js");

router.post('/register', registerUser);
router.post('/login', loginUser);

module.exports = router;

Solution

Found the error. I was using my route middleware before using the cookie and it was somehow throwing this error. sorry, for not providing the complete code, and thanks for all the reply.

Answered By – totalNoob

Answer Checked By – Timothy Miller (BugsFixing Admin)

Leave a Reply

Your email address will not be published.