For put and post, why do I need to store the callback call in a variable?

Hi there, I am currently working on the Express Cumulative Project (Boss Machine):

It gave me a hard time yesterday, because I couldn’t get the post and put routes to work. I finally peeked at the solution. I found out that my fault was simply not to store the callback call in a variable:’/’, (req, res, next) => {
const newMinion = addToDatabase(‘minions’, req.body);

Why is that necessary? Why can I not just call ‘addToDatabase(‘minions’, req.body);’ ?



1 Like