Elixor
  • Elixor
  • Setup
  • Making a GET request
    • Why write a separate service file
    • Type-checking the response
    • Reading the full response
  • Sending data to the server
    • Adding headers
    • Making a POST request
    • Making a DELETE request
    • Making a PUT request
  • Error handling
    • Getting error details
    • retry()
  • Observables and operators
  • Requesting non-JSON data
  • Advanced Usage
    • Configuring the request
    • Debouncing requests
    • Intercepting requests and responses
    • Listening to progress events
  • Security: XSRF Protection
Powered by GitBook
On this page

Was this helpful?

  1. Sending data to the server

Making a PUT request

​An app will send a PUT request to completely replace a resource with updated data. The following HeroesService example is just like the POST example.

heros.service.ts
/** PUT: update the hero on the server. Returns the updated hero upon success. */
updateHero (hero: Hero): Observable<Hero> {
  return elixor.put<Hero>(this.heroesUrl, hero, httpOptions)
    .pipe(
      catchError(this.handleError('updateHero', hero))
    );
}

The caller (HeroesComponent.update() in this case) must subscribe() to the observable returned from the elixor.put() in order to initiate the request.

PreviousMaking a DELETE requestNextError handling

Last updated 6 years ago

Was this helpful?