This adds support for optionally specifying an error interceptor for responses. The idea is that this interceptor would allow you to run centralized handlers for certain types of errors, without affecting the outcome of the response. For example, you could write an error interceptor to "handle" 401 responses by redirecting back to login, or a general 400-500 error interceptor that shows a toast notification.
The signature of the interceptor is statusCode: int -> responseBody: string -> unit. You can set up the interceptor by calling Remoting.withErrorInterceptor:
let errorInterceptor statusCode responseBody =
match statusCode with
| 401 -> redirectToLogin()
| 500 -> console.log "error"
| _ -> ()
let musicStore =
Remoting.createApi()
|> Remoting.withErrorInterceptor errorInterceptor
|> Remoting.buildproxy<IMusicStore>
This adds support for optionally specifying an error interceptor for responses. The idea is that this interceptor would allow you to run centralized handlers for certain types of errors, without affecting the outcome of the response. For example, you could write an error interceptor to "handle" 401 responses by redirecting back to login, or a general 400-500 error interceptor that shows a toast notification.
The signature of the interceptor is
statusCode: int -> responseBody: string -> unit
. You can set up the interceptor by callingRemoting.withErrorInterceptor
: