following are my code , It is running well if , I find from database but its only saving IDs into database on create method
const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const app = express();
// create application/json parser
app.use(bodyParser.json())
// create application/x-www-form-urlencoded parser
app.use(bodyParser.urlencoded({ extended: false }))
mongoose.connect('mongodb://localhost/quicks');
const db = mongoose.connection;
const userSchema = mongoose.Schema({
name: String
});
const User = mongoose.model('user', userSchema);
app.get('/', (req, res) => res.send('Hello World!'))
app.post('/createuser', (req, res) => {
let value = {
name : req.body.Name,
email : req.body.Email,
password : req.body.Password
};
User.create(value)
.then((records) => {return res.json(records)})
.catch((err) => {return res.json("err")})
})
app.post('/user', (req, res) => {
let value = {
_id : req.body.ID
};
user.findOne(value)
.then((records) => {return res.json(records)})
.catch((err) => {return res.json("err")})
})
app.listen(4000, () => console.log('Example app listening on port 4000!'))
i am not able to get the data which i have created . Only the ID is created. what would be the possible error?