1. Check any possible typos
2. Calm down and read the code
comment every code step by step
3. Debugging. go back to step 2 till you figure the matter out
keep searching while looping step 2 and 3
I code to be into it not to be mat at it
HAPPY CODING!
2. Calm down and read the code
comment every code step by step
3. Debugging. go back to step 2 till you figure the matter out
keep searching while looping step 2 and 3
I code to be into it not to be mat at it
HAPPY CODING!
app.post('/meower', (req,res) => {
console.log('1. POST /mews request');
if(isValidMew(req.body)) {
console.log('2.A. Body is valid');
const mew = {
name: req.body.name.toString,
content: req.body.content.toString,
created: new Date(),
};
mews
.insert(mew)
.then(createdMew => {
console.log('3.A Mew has been created');
console.log(createdMew);
//TODO
})
.catch(err => {
console.log('3.B Mew creation has failed');
console.log(err)
});
} else {
console.log('2.B. Body is invalid');
res.status(422);
res.json({
message: 'Hey! Name and Content are required!'
});
}
});
app.listen(5000, () => {
console.log('Listening on http://localhost:5000');
});
댓글
댓글 쓰기