
We need to import body-parser into our index.js While there is a lot more to learn about requests and data, everything you need to know to get a basic understanding of a request sending data in a node.js API will be explained here very soon.
It is very simple to set up in our index.js. This can come in the form of route parameters (just like in the user interface, something like id in the route /user/123), but also an API needs the ability to take data from a request's body.īody-parser will allow a node API to parse the request's body into a JSON object so our node API can use that data. We have one more npm package we haven't used yet.Īn API needs to be able to take data from the requests made to it. We have used the express and nodemon npm packages so far. If your server is not running, run it again with: npm run start. "Node Todo API is running on port: 5001" in our console. If our node server is still running, we should see the message:
On a command line, navigate to the directory that you'd like to store your project in and create a new directory. This will help you a lot to understand node.js, APIs, and code in general Take your time with this tutorial and try to understand each piece before moving onto the next. The difference between a good developer and a bad developer, is that when the good developer gets stuck, he or she can get themself unstuck by being resourceful and searching for the solution. A good software developer gets stuck, it is not a sign of weakness or ignorance. If you come across something you are unsure of, it is important to search around on google, stack overflow, forums, etc. This tutorial will have server side routing and the functionality to Create, Read, Update, and Delete items using nodeJS and express.īefore we get started, no tutorial will not be able to explain everything about building a node API. We will build a very basic REST API for a todo-list app. A terminal you enjoy using such as cmd, powershell, or cmder. (Should be installed with node above, or here) You will also need these system requirements: Enter fullscreen mode Exit fullscreen mode