Router
: route the request to corresponding function the controllerController
: responsible for processing request and responsibleService
: handle the business logic
-
In a class method,
getTweets = (req, res) => { console.log(this); };
The
this
here is pointing to the instance of the class. However, a small change here:getTweets(req, res){ console.log(this); }; OR getTweets = function(req, res){ console.log(this); };
This won't work as expected, because the
this
keyword is not pointing to the instance, instead it points toundefined
somehow. Hence to avoid this, rule of thumb is always use the method above to declare class method!