Creating APIs

The next important step is creating routes. It is always recommended to follow modularity whenever we implement routes in any framework for the longtime maintainability of code. That being said, let's create a routes.js file. As we are not going to use any database such as MongoDB or MySQL, let's create a json file called phonebook.json for a supportive data source. Let's create the following data in a json file:

{
"list": [
{
"phone_no": 1212345678,
"name": "Batman"
},
{
"phone_no": 1235678910,
"name": "Superman"
},
{
"phone_no": 9393939393,
"name": "Flash"
}]
}

The structure of our API directory is as follows:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.227.9