Guest User

Untitled

a guest
May 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. {
  2. "error": {
  3. "message": "Cannot read property 'DiseaseID' of undefined"
  4. }
  5. }
  6.  
  7. exports.UserDiseaseInfo = (req, res,next) => {
  8.  
  9. let retval = {};
  10. let body = req.body;
  11. let UId = (body.UId != undefined) ? body.UId : false;
  12. let SubDId = (body.SubDId != undefined) ? body.SubDId: false;
  13.  
  14. if(UId==false||SubDId==false){
  15. res.status(404).send({response:"Fail", body: req.body});
  16. }
  17. var subd = subDisease_model.findById(SubDId);
  18. let data = {
  19. response:'success',
  20. subDisease : "XX",
  21. diseaseId : subd[0].DiseaseID
  22.  
  23. }
  24. res.status(200).send(data);
  25. };
  26.  
  27. const mongoose = require('mongoose');
  28. const AddictionsSchema = new mongoose.Schema({
  29. DiseaseID : mongoose.Schema.Types.String,
  30. SubDisease : mongoose.Schema.Types.String
  31. });
  32. module.exports = mongoose.model('SubDiseaseMaster', AddictionsSchema, 'SubDiseaseMaster');
  33.  
  34. db.SubDiseaseMaster.find({})
  35. { "_id" : ObjectId("5ad0850efdcab0ab875c4890"), "DiseaseID" : "5ad06decfdcab0ab875c4838", "SubDisease" : "Acidity" }
  36.  
  37. POST /api/UserDiseaseInfo HTTP/1.1
  38. Host: 1nature.in
  39. Content-Type: application/json
  40. Cache-Control: no-cache
  41. Postman-Token: 62e22748-5c30-3f4b-4852-fc0bab68db0d
  42.  
  43. {
  44. "UId":"A",
  45. "SubDId": "5ad0850efdcab0ab875c48a4"
  46. }
Add Comment
Please, Sign In to add comment