---
title: "Discussion on \"Build a REST API with Node.js: Finalizing Controllers\" | Hashnode"
description: "Discussion on \"Build a REST API with Node.js: Finalizing Controllers\". Hello everyone! Welcome back to Let's Build a Node.js REST API Series. In the previous article, we have integrated our API with MongoDB and set up our Mongoose model. We are now ready to remove the dummy functions in our controller and add actual fun..."
url: "https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Build a REST API with Node.js: Finalizing Controllers](https://blog.lo-victoria.com/build-rest-api-with-nodejs-controllers?utm_source=hashnode&utm_medium=feed)

Hello everyone! Welcome back to Let's Build a Node.js REST API Series. In the previous article, we have integrated our API with MongoDB and set up our Mongoose model. We are now ready to remove the dummy functions in our controller and add actual fun...

Aug 6, 2020 · 9 min read · blog.lo-victoria.com  
Updated Oct 12, 2021  
Read the article

-   [#nodejs](https://hashnode.com/tag/nodejs)
-   [#mongodb](https://hashnode.com/tag/mongodb)
-   [#rest-api](https://hashnode.com/tag/rest-api)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#beginners](https://hashnode.com/tag/beginners)

## Written by

[Victoria Lo](https://hashnode.com/@victoria)

@victoria · Singapore

  
[View profile](https://hashnode.com/@victoria)

A nerd in books, tea, games and software.

I'm a solutions engineer lead, GitHub Star, Director of WomenDevsSG, and co founder of ragTech. I work at the intersection of tech, systems, and leadership, and this blog is where I share my journey through all three. Expect honest reflections, real experiences, and thoughts that are still forming rather than polished career advice.

## Responses 10

Markdown supported · ⌘↵ to post

[Valentina Maraio](https://hashnode.com/@valentina464)

[Jan 13, 2023](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/63c19bba74f4982355656f0a)

Love the series! but i do not understand how to add new tea to the db. I'm writing the newTea as in the code example but it doesn't work :(

[Lauren Lucero](https://hashnode.com/@LaurenBreathes)

[Mar 30, 2021](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/6063494426d9c50a54bab9b9)

I am stuck on the newTea POST. My teas are posting but only with \_id, comments, and \_\_v properties. Attached are screenshots of my postman and MongoDB as well as my GH repo. I've reviewed my code and restarted the server multiple times to no avail. From what I can test, the other controllers all seem to be working. Any advice or feedback is appreciated. Thank you! ![Screen Shot 2021-03-30 at 11.42.19 AM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1617118948551/zq05Q_6T8.png) ![Screen Shot 2021-03-29 at 3.40.23 PM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1617118915020/ekKYFCdDc.png) [Repository](https://github.com/laurenlucero/tea-api)

[Victoria Lo](https://hashnode.com/@victoria)

[Mar 31, 2021](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/6063494426d9c50a54bab9b9#reply-60649ba4574933157db92f9b)

Hi [Lauren Lucero](https://hashnode.com/@LaurenBreathes), thanks for mentioning the issue! I wrote this tutorial after completing the final product so I forgot to include the "in-between" code for testing, since it will be deleted in the next part.

I have updated the article (newTea section). Please have a look and add the changes accordingly. Thanks!

[Sidharth Kumar](https://hashnode.com/@Sidk)

[Feb 2, 2021](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/6018c5d371a0a26a8eebbf6e)

Awsome article.. Clearly explained with all core working links. hey Victoria, Do you have any youtube channel.? I would love to subscribe?

[Victoria Lo](https://hashnode.com/@victoria)

[Feb 2, 2021](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/6018c5d371a0a26a8eebbf6e#reply-6018e45671a0a26a8eebc204)

Thanks for the nice comment! No, I don't have one.. but thanks for the thought to subscribe :D

[Rhys Davies](https://hashnode.com/@rhys-the-davies)

[Jan 16, 2021](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/600328f87b30c23b714a9252)

I'm trying to follow along and loving the series, very well written and well explained. Thank you [Victoria Lo](https://hashnode.com/@victoria) :) But I'm running into an issue at the "Testing with POSTman" step.

Everything works up until this point except when I hit "send" in postman it throws me a ValidationError saying "path 'name' is required' in the form. When in fact, it's there. While trying to debug I found that the database and postman are connected correctly because if I set a default name it sends to Mongo no problem. But if the entry is not already given in schema in the "models" folder it doesn't send. Everything else works up to this point but I can't find my problem :( Any ideas?

[Victoria Lo](https://hashnode.com/@victoria)

[Jan 17, 2021](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/600328f87b30c23b714a9252#reply-6003963d7b30c23b714a96a2)

Hi [Rhys Davies](https://hashnode.com/@Tinkererbell), thanks for the question. Which method were you having issues with? GET POST or DELETE?

First, try to check the URL you've supplied on POSTman. Did you pass in a name as params? Like `[localhost/tea/<tea-name>](http://localhost:3000/tea/%3Ctea-name%3E)`?

Please check the code too.

```
let name = req.params.name; // is correct
// some may wrote as req.body.name, which is incorrect
```

You can also try StackOverflow if all else fails: [stackoverflow.com/questions/58671337/postman-erro…](https://stackoverflow.com/questions/58671337/postman-error-validationerror-username-path-username-is-required)

[Atul](https://hashnode.com/@Atul07)

[Jan 26, 2022](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/600328f87b30c23b714a9252#reply-61f0e39687fd2728e7cd4c49)

I am also facing this error for POST. newTea function is not working. It fails with error: "Tea validation failed: name: Path `name` is required."

Despite 'name' field is present in 'body' as 'form data' [Victoria Lo](https://hashnode.com/@victoria)

[Fernando Torres](https://hashnode.com/@fertorresmx)

[Sep 28, 2020](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/5f717edc1c510d72d074a181)

Hi! I like so much your series. Thanks for share your knowledge.

I'm trying to code your tutorial on my own repo, but at this point, I can't make that two routes works like this post.

When I'm trying to delete a tea that is not on the collection, the message is the same "Tea deleted". But it dont delete any record, because it doesn't exist at all. Here I'm expecting the message "Tea doesn't exist."

And when post twice a new tea, with all the same values, it insert it anyway when we expect the message "Tea already exists".

The commit is [here](https://github.com/FernandoTorresL/Victoria-Lo_TAPI/commit/386e1eb7862e03cf7b7db61c6d771d5f5c396e8a)

I'm going to finish the proyect anyway and expect to solve in the future this issues.

[Victoria Lo](https://hashnode.com/@victoria)

[Jan 17, 2021](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/5f717edc1c510d72d074a181#reply-6003969d7b30c23b714a96a6)

Hi, sorry for the late reply. I see that you've completed the project and solve the issues yourself :)

[Rajat Verma](https://hashnode.com/@rajat2502)

[Aug 19, 2020](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/5f3d3e85456c1732011260fd)

Hey [Victoria Lo](https://hashnode.com/@victoria), Great series till now!!! Helped me to recall the basics. Just a suggestion: it would be much easier to understand if you have used async/await or promise.then/.catch in place of callbacks.

[Aug 19, 2020](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/5f3d3e85456c1732011260fd#reply-5f3d3ffa456c173201126116)

Thanks Rajat for enjoying the series and thanks for the feedback!

I see, I thought it would be simpler for beginners if I exclude the concept of Promises and async/await. I'll keep that in mind for future articles :) Thanks again!

[Bolaji Ayodeji](https://hashnode.com/@bolajiayodeji)

[Aug 6, 2020](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/5f2bb2f7eb31e259cffbca58)

The world needs to follow this series. This is just the perfect mini-nodejs course.

Well done [Victoria Lo](https://hashnode.com/@victoria)!

[Victoria Lo](https://hashnode.com/@victoria)

[Aug 6, 2020](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/5f2bb2f7eb31e259cffbca58#reply-5f2bf22c3b12e25afe3e3ca7)

Hahaha yeah! Thanks Bolaji for the amazing support and comment 🙏

[Subha Chanda](https://hashnode.com/@nemo)

[Aug 6, 2020](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/5f2b8c9c3dddda50802a8f2e)

Another simple but solid explanation. 😃

[Victoria Lo](https://hashnode.com/@victoria)

[Aug 6, 2020](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/5f2b8c9c3dddda50802a8f2e#reply-5f2bf1e13b12e25afe3e3ca0)

Yay! Always glad you're enjoying this series Subha :)

[Tapas Adhikary](https://hashnode.com/@atapas)

[Aug 6, 2020](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/5f2b83ab3dddda50802a8ece)

I am following it and loving it!

[Victoria Lo](https://hashnode.com/@victoria)

[Aug 6, 2020](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/5f2b83ab3dddda50802a8ece#reply-5f2b85963dddda50802a8efb)

Thank you! That makes me very happy :)

[Richard Harris](https://hashnode.com/@richard788)

[Aug 6, 2020](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/5f2b6bb91d274050a13a20c3)

Really though, this series gets better and better.. 👏👏

[Victoria Lo](https://hashnode.com/@victoria)

[Aug 6, 2020](https://hashnode.com/posts/build-rest-api-with-nodejs-controllers/5f2b6a5f3dddda50802a8e5a/comment/5f2b6bb91d274050a13a20c3#reply-5f2b85ab1d274050a13a2141)

Thanks Richard :) That's awesome!
