710 viewsMern Amazona

in video 22 create signin api i try advanced rest client to post http://localhost:5000/api/users/signin but it comes with error 401 unauthorized and says

"message": "Invalid email or password"

i seen a similar question and you said to console.log(user) before if statement and it comes up as null

Bassir Edited question February 8, 2024

when you get this error it means either the email and password didn’t go to backend or a user with this email and password doesn’t exist in the db:

for reason 1: you need to check what you pass to the backend using console.log(req.body) in this line:

for reason 2: check db with mongodb compass to see if user with this email exists. if not create a new user in the app and login again.

Bassir Answered question March 9, 2023
You are viewing 1 out of 1 answers, click here to view all answers.