@serenity-is/corelib / ServiceOptions
Interface: ServiceOptions<TResponse>
Defined in: src/base/servicetypes.ts:218
Options for serviceCall / serviceRequest / serviceFetch.
Extends the native RequestInit so any fetch option (e.g. signal, cache) can be passed through.
Extends
RequestInit
Type Parameters
TResponse
TResponse extends ServiceResponse
Expected service response type (must extend ServiceResponse).
Properties
allowRedirect?
optionalallowRedirect:boolean
Defined in: src/base/servicetypes.ts:220
When true (default), a 403 with a Location header triggers a top-window redirect.
Default Value
true
async?
optionalasync:boolean
Defined in: src/base/servicetypes.ts:222
When false a synchronous XHR is used (blocks the UI). Prefer true (default).
Default Value
true
blockUI?
optionalblockUI:boolean
Defined in: src/base/servicetypes.ts:224
When true (default) the UI is blocked with a loading indicator for the duration of the request.
Default Value
true
errorMode?
optionalerrorMode:"none"|"alert"|"notification"
Defined in: src/base/servicetypes.ts:234
How service errors are surfaced to the user. "alert" shows a dialog, "notification" shows a toast, "none" suppresses default handling.
headers?
optionalheaders:Record<string,string>
Defined in: src/base/servicetypes.ts:226
Extra HTTP headers merged with defaults (Accept: application/json, Content-Type: application/json, X-CSRF-TOKEN when same-origin).
Overrides
RequestInit.headers
request?
optionalrequest:any
Defined in: src/base/servicetypes.ts:228
Request DTO serialized as JSON in the POST body.
service?
optionalservice:string
Defined in: src/base/servicetypes.ts:230
Service endpoint key (e.g. "Administration/User/List"). Resolved via ~/Services/ when relative. Mutually exclusive with url.
url?
optionalurl:string
Defined in: src/base/servicetypes.ts:232
Absolute or ~/-prefixed URL. When provided service is ignored.
Methods
onCleanup()?
optionalonCleanup():void
Defined in: src/base/servicetypes.ts:236
Callback invoked after the request finishes regardless of success or failure (after blockUI is undone).
Returns
void
onError()?
optionalonError(response,info?):boolean|void
Defined in: src/base/servicetypes.ts:243
Custom error handler. Return true to indicate the error was handled and suppress default error display.
Parameters
response
TResponse
Parsed service response (may be null for network / HTTP errors).
info?
HTTP-level error details.
Returns
boolean | void
true if handled (prevents double notification), false/void to allow default handling.
onSuccess()?
optionalonSuccess(response):void
Defined in: src/base/servicetypes.ts:248
Success callback invoked with the parsed response when Error is not set.
Parameters
response
TResponse
Successful service response.
Returns
void