O'Reilly logo

Hands-On Full Stack Web Development with Aurelia by Erikson Haziz Murrugarra Sifuentes, Diego Jose Arguelles Rojas

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

Using routes

Routes are the magic behind our RESTful API. If you remember when we talked about HTTP verbs, RESTful is composed by combining CRUD operations with the HTTP verbs. Express.js makes easy the definition of these RESTful way. For example, open the server.js file and apply the following change:

...app.get('/hello', (req, res) => {    res.send("Hello!")})...

As you can see, we changed use for get. As you are so smart, you know that get refers to the GET HTTP verb, so let's define our RESTful routes for our Teams API. In the server.jsapply the following changes:

...app.get('/teams', (req, res) => {    res.send("To retrieve the list of teams")})app.post('/teams', (req, res) => {    res.send("To create a new team")})app.put('/teams', (req, ...

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