Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

491
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda