From the course: Node.js: Microservices

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Completing the API

Completing the API

- [Instructor] So we just successfully created our first route. Now I want to create a route that returns exactly one item. And for that I will first just copy the route that I have already because it's pretty similar. The only big difference right from the start is that I want to pass in colon id. So this creates a variable ID that can be passed in via the URL path. And down here I will now apply this by saying const item because it's just one item. And catalog service has a method for me that is just simply called getOne to return one item. Now I'm passing in request dot params and the id. So this now points to the ID that was passed in via this URL path. And in the end, all I have to do is to return this item, make sure to rename the variable done here in line 20. So this is done. Next I want to add a route that will create a new item. And for that I again copy the first route that we created and paste it…

Contents