From the course: Building Angular and Django Apps

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Partially updating an item using Angular

Partially updating an item using Angular

From the course: Building Angular and Django Apps

Start my 1-month free trial

Partially updating an item using Angular

- We're able to create new tour packages, list them, and delete them and now it would be nice to be able to update them as well. So in the rest-api.service we're going to add a new method called updateTour. It's going to take tourPackageData as a parameter. And then we're going to start constructing this API request by extracting some of the data we need to transform before we send it over. And then we're going to call http.put and the URL will be /api/v1/packages. Because we're updating an existing package, we can use the ID that were given in the tour package data. And now the data we're going to send will be the start date, formatted in a specific way, and the tour_length needs to be renamed, and then we pass in the rest of the data. We also need the commonOptions that we use, which would include the oauth token that we need to make this request. Now, in tour-package-controller, we're going to update the save method…

Contents