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

490
Views
status : 500 Internal Server Error postman only posts empty curly brackets when enter the data on the body

and this is my code (index.js), (auth.js)

const express = require("express");
const dotenv = require("dotenv");
const mongoose = require("mongoose");
const authRoute = require("./routes/auth");
const app = express();

dotenv.config();
app.use(express.json());


mongoose.connect(process.env.MONGO_URL, {
    useNewUrlParser: true,
    useUnifiedTopology: true,
    useCreateIndex: true,
  }).then(console.log("Connected to MongoDB"))
  .catch((err) => console.log("err"));
app.use("/api/auth",authRoute );

app.use("/api/auth",authRoute);


app.listen("3000", () => {
  console.log("Backend is running.");
});

const router = require("express").Router();
const User = require("../models/User");

//REGISTER
router.post("/register", async (req, res) => {
  try {
    const newUser = new User({
      username: req.body.username,
      email: req.body.email,
      password: req.body.password,
    });

    const user = await newUser.save();
    res.status(200).json(user);
  } catch (err) {
    res.status(500).json(err);
  }
});

//LOGIN


module.exports = router;
and image of the postman result 
when I send the request postman posts empty curly brackets. I want to get the post data on the down of the body at the postman

screenshot of the postman

and this is what terminal logs result on the terminal

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You should check what receives in user object at const user = await newUser.save();

data would be in user.data

or use json instead,

 const user = await newUser.save();
    res.status(200).jsonp(user);
about 4 years ago · Juan Pablo Isaza Report
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!