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?

Error handling

What happens if the request fails on the server, or if a poor network connection prevents it from even reaching the server?Elixor will return an error object instead of a successful response.

You could handle in the component by adding a second callback to the subscribe():

Home.tsx
showConfig() {
  getConfig()
    .subscribe(
      (data: Config) => this.config = { ...data }, // success path
      error => this.error = error // error path
    );
}

It's certainly a good idea to give the user some kind of feedback when data access fails. But displaying the raw error object returned by Elixor is far from the best way to do it.

PreviousMaking a PUT requestNextGetting error details

Last updated 6 years ago

Was this helpful?