title: How can i sent reponse back to postman in nodejs from a function?
body: <p>I have a code which takes students details from json and insert to mongodb database. I have some validation checks in my schema for studentId unique etc.. when I save my data to mongodb I would like to get the response in postman, how can iget in postman, I tried below code to write response to poatman. Don't know if its correct, printing error in console is working, how can I get the same in postman? </p>
  
  <pre><code>function SaveToDatabase(student){ 
    student.save((err, student)=&gt; {
       if(!err){
        console.log('insertion to db sucess')  
        res.send({ response: inserted });
  
       }
       else{
          console.log('insertion failed '+err);
          res.send({ error: err });
       }
    },function (err, inserted) {
      if (err) {
          res.send({ error: err });
      } else {
          res.send({ response: inserted });
      }
  }
    );//save
  
  }
  </code></pre>