mongoose에서
var listSchema = new Schema({
title:{
type:String,
require:true,
},
date:{
type:Date,
default:new Date(),
},
isDone:{
type:Boolean,
default:false,
}});
var Todos = mongoose.model('todos',listSchema);
app.get('/getList',async (req,res)=>{
let result = await Todos.find({});
return res.status(200).json({
data:result
});
});
app.post('/postList',async(req,res)=>{
let new_todo = new Todos(req.body);
try{
await new_todo.save();
return res.status(200).json({
message:'success!',
data:new_todo
});
}catch(e){
return res.status(500).json({
message:'error',
E:e
});
}});
/postList로
하고서 getList하면
title이 안나오는데 해결방법이 있을까요?
(postList에서 "Test"로 해봐도 안나옴)