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

72
Visualizações
postman does not store value

So I am trying to enter a post using postman into a mongo db server but my post just returns empty. When I look into my server nothing has been entered and there is no error

Route file

router.post('/', async (req,res) => {
const post = new customer({
    fullName: req.body.fullName,
    id: req.body.id
});
try{
    const savedCust = await customer.save();
    res.json(savedCust);
} catch (err) {
    res.json({message: err});
}
});

module.exports = router;

This is what I submit on postman:

{
    "fullName" : "Tim Scott",
    "id": 87438
}

And this is the response that I get back:

{
    "message": {}
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The error said that customer.save() isn't a function. This happened in your try {...} block inside your route file. The reason for that is that it's not a function. You should be doing post.save():

// route file
const express = require('express');
const router = express.Router();
const customer = require('../models/customer');
router.post('/', async (req,res) => {
  const post = new customer({
    fullName: req.body.fullName,
    id: req.body.id
  });
  try {
    const savedCust = await post.save(); // right here
    res.json(savedCust);
  } catch (err) {
    res.json({message: err});
  }
});

module.exports = router;
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