Check out a free preview of the full API Design in Node.js (using Express & Mongo) course:
The "Exercise 10" Lesson is part of the full, API Design in Node.js (using Express & Mongo) course featured in this preview video. Here's what you'd learn in this lesson:

In this exercise, you will connect the routes with their controller methods.

Get Unlimited Access Now

Transcript from the "Exercise 10" Lesson

[00:00:00]
>> [MUSIC]

[00:00:03]
>> Speaker 1: So the first thing you want to do is on step ten that's where we left off with the controllers. We just need to hook up the routes so if we go to the API and go to the routes, all these routes are here, but they don't have their crud on them.

[00:00:23] Right so they need stuff like .get and then we need to be able to call the controllers that we already have here and represent the appropriate functions. So for example I'm just gonna walk through one right now. So this is the category route. So on a get request to/API/category, I want to run the,

[00:00:46]
>> Speaker 1: controller.get method. And I get controller up here because I say var controller equals require the category controller.
>> Speaker 2: You typed request there.
>> Speaker 1: Thanks.
>> Speaker 1: So now I can run controller.get which if you go look at the controller is right here. That's why we exported these, so that we can require them here.

[00:01:18] And then we'll do the same thing for all the other routes.