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

Retrieving the list

We already have the list handler, but the listing is not enough. Apart from retrieving the full list, we will need to retrieve a single team. To do this, we will need to add a new GET route and learn how to use params. Apply the following changes into the teams-api.js:

...api  .route('/teams')...api  .route('/teams/:id')  .get((req, res) => {      const id = req.params.id      for(let team of teams) {          if (team.id == id)            return res.json(team)      }      return res.status(404).send('team not found')  })module.exports = api

First, we declare a new route, which now contains a dynamic param—/teams/:api. We said dynamic because, of course, it can take any value that will be available as an attribute of the req.params object. Note that the name you ...

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