From the course: Angular: Testing and Debugging

Unlock the full course today

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

Updating data using REST requests

Updating data using REST requests - Angular Tutorial

From the course: Angular: Testing and Debugging

Start my 1-month free trial

Updating data using REST requests

- In the last video, we added the getRemote method here in our web storage service. Next, we'll write a method called setRemote, which will use the HTTP instance to set the filter state in our database. We do this by making a new line and typing public, setRemote, open close parentheses, open close curly brackets. This method will take one argument: The payload we want to send to the server. I'm going to call it payload. Very clever, I know. It's going to be of type string because this payload represents the filter string passed in from our HTML template. This is a very simple payload, but payloads can be of any size or shape. Really, it all comes down to what the server expects to receive. Inside this method, we'll use the HttpClient instance to send data to a URL. I'll make a new line and type this, .http.put, open close parentheses. The HTTP PUT method lets us update existing records in a database. It takes three arguments. The first is a URL string pointing to the location on the…

Contents