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

Updating teams

To update our teams, first we will need to look for an existing team in our database using the ID provided in the path. If a team is found, we apply the changes to the team object. So, let's start adding the following code:

api  .route('/teams/:id')  .get((req, res, next) => {     ...  })  .put((req, res, next) => {    let id = req.params.id        Team.findById(id)      .then(data => {        if (data == null) {          throw new Error("Team not found")        }        return data      })      .then(team => {        // We found the team.         // Code to update goes here!      })      .catch(err => next(err))  })  .delete((req, res) => {
    // TODO  })...

First, we extract the id passed in the endpoint. Then, we call the findById method to look for an existing team. If a valid team is found, we will have a

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