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

Listing the teams

To retrieve the full list of teams, we will make use of the GET HTTP method. Let's start by cleaning up our code a little bit. Until now, we have been using an array of teams; we won't need it anymore, so let's remove it. In src/routes/teams-api.js, apply the following changes:

...api  .route('/teams')  .get((req, res) => {    // TODO  })  .post((req, res, next) => {    let team = new Team(req.body)    team.save()      .then(data => res.json(data))      .catch(err => next(err) )  })api  .route('/teams/:id')  .get((req, res) => {      // TODO  })  .put((req, res) => {    // TODO  })  .delete((req, res) => {    // TODO  })...

Now that we have our code cleaned, add the following change to implement the logic to retrieve the full list of teams:

...api .route('/teams') ...

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