I'm trying to request a date in node from angular. What do i put in post router to req the date?
This is my angular code for a customer object
customers: Customer[];
customer: Customer;
firstName: string;
lastName: string;
today: number= Date.now();
addCustomer(){
const newCustomer = {
firstName: this.firstName,
lastName: this.lastName,
today: this.today
}
My router to post the customer in the database looks like this
router.post('/customers', (req,res,next) =>{
let newCustomer = new Customer({
firstName: req.body.firstName,
lastName: req.body.lastName,
});
newCustomer.save(function(err, Customer){
if (err){
res.json({msg: 'Failed to add contact'});
}else{
res.json({msg: 'Customer added to waitlist'});
}
});
});
via TexasState Han
No comments:
Post a Comment