O'Reilly logo

Learning Node.js for Mobile Application Development by Milorad Jevdjenic, Stefan Buttigieg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building a RESTful API with Node.js

Now that we have covered the basics of REST, let's put it into practice and build an API for OrderBase, which was constructed in the previous chapter. If you have not done so already, please take a moment to review the code that we wrote there in order to make sure that you understand what happens between our API and the database in this example.

Setting up the RESTful API

Start with creating a workspace for our server. On your drive, create a folder named order_api, step into this folder, and create and execute the file named api.js. Finally, open a terminal and execute the following:

npm init

As we saw in the previous chapter, this will give you a few questions to answer in order to bootstrap the Node.js server. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required