Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

270
Views
React.js Axios 400 (Bad Request) to backend node.js passport.js

The problem is that when i make post request via postman localhost:3005/api/users/signup it creates user in database and everything works. but when i try to post from front-end using Axios it shows 400 bad request

Here is my front end code to how i'm calling post request. addUser has the same structure of what im posting via postman.

postUser: async (addUser) => {
    await axios.post(`${APIURLusers}signup/`, {addUser});
},

If POST via postman works i think the error is on the react side but here is backend code router.js

router.post(
'/signup',
passport.authenticate('signup', { session: false }),
async (req, res, next) => {
  res.json({
    message: 'Signup successful',
    user: req.user
  });
});

and auth.js

passport.use(
'signup',
new localStrategy(
  {
    usernameField: 'email',
    passwordField: 'password',
    passReqToCallback: true
  },
  async (req,email, password, done) => {
    try {
        const data = new UserModel({
            firstName: req.body.firstName,
            lastName: req.body.lastName,
            phone: req.body.phone,
            email: email,
            password: password
        });

        data.save();
      return done(null, data);
    } catch (error) {
        console.log(error);
      done(error);
    }
  }
)

);

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!