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 a Team

The update process is a combination of two processes—the search for a team and the update process itself. In the previous implementation, we wrote the code to look up an existing team. So, let's reuse the same code by defining a function that can be used for retrieve, update, and delete. Open the teams-api.js file and apply the following changes:

...let teams = [    { id: 1, name: "Peru"},    { id: 2, name: "Russia"}]function lookupTeamIndex(id) {    for(var i = 0; i < teams.length; i++) {        let team = teams[i]        if (team.id == id)          return i    }    return -1}api  .route('/teams')...

We created the lookupTeam function, which expects for the id as a param and will return a valid team index if it is found. Otherwise, it will return -1. Now we need ...

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