One of the most important aspects of our API are routes that we take to create, read, update, and delete our speakers.
Our routes are based on the HTTP verb used to access our API, as shown in the following examples:
To create record, use the POST verb
To read record, use the GET verb
To update record, use the PUT verb
To delete records, use the DELETE verb
So, our routes will be as follows:
Routes |
Verb and Action |
---|---|
| |
|
POST inserts speakers' record |
| |
|
PUT updates a single record |
|
DELETE deletes a single record |
Configuring the API routes:
Let's start defining the route and a common message for all requests:
var Speaker = require('./server/models/speaker'); // Defining the Routes for our API // Start the Router var router = express.Router(); // A simple middleware to use for all Routes and...