This module should be mixed into any widget or service that needs to make XHR calls to REST APIs on
either the client or the Alfresco Repository.
- Support:
-
- This module is safe to be mixed into 3rd-party widgets and services (at least until the next major release).
- Copyright:
- Copyright (C) 2005-2020 Alfresco Software Limited
- License:
- GNU Lesser General Public License, see: Open Source Licensing
- Source:
Members
-
encodeURIs :boolean
-
Indicates whether or not to call the JavaScript encodeURI function on URLs before they are passed to serviceXhr. This defaults to true but can be overridden if required.
Type:
- boolean
- Default Value:
- false
- Source:
-
preventCache :boolean
-
Should a cache busting parameter be added to the URL?
Type:
- boolean
- Default Value:
- false
- Source:
Methods
-
cleanupJSONResponse(input) → {string}
-
This function can be used to clean up JSON responses to remove any superfluous whitespace characters and remove any trailing commas in arrays/objects. This function is particularly handy since Dojo can be very fussy about JSON.
Parameters:
Name Type Description input
string - Source:
Returns:
A cleaned up JSON response.- Type
- string
-
constructor(args)
-
Ensures that the csrfProperties are retrieved from the Alfresco constants provided by Surf.
Parameters:
Name Type Description args
object The constructor arguments. - Source:
Listens to Events:
-
csrfResolve()
-
- Source:
-
defaultFailureCallback(response, requestConfig)
-
This is the default failure callback for XHR requests that will be used if no other is provided.
Parameters:
Name Type Description response
object The object returned from the failed XHR request requestConfig
object The original configuration passed when the request was made - Source:
-
defaultProgressCallback(response, requestConfig)
-
This is the default progress callback for XHR requests that will be used if no other is provided.
Parameters:
Name Type Description response
object The object returned from the progress update of the XHR request requestConfig
object The original configuration passed when the request was made - Source:
-
defaultSuccessCallback(response, requestConfig)
-
This is the default success callback for XHR requests that will be used if no other is provided.
Parameters:
Name Type Description response
object The object returned from the successful XHR request requestConfig
object The original configuration passed when the request was made - Source:
-
getCsrfCookie() → {String}
-
Returns the name of the cookie that holds the value of the token.
- Source:
Returns:
The name of the request header to put the token in.- Type
- String
-
getCsrfHeader() → {String}
-
Returns the name of the request header to put the token in when sending XMLHttpRequests.
- Source:
Returns:
The name of the request header to put the token in.- Type
- String
-
getCsrfParameter() → {String}
-
Returns the name of the request parameter to put the token in when sending multipart form uploads.
- Source:
Returns:
The name of the request header to put the token in.- Type
- String
-
getCsrfToken() → {String}
-
Returns the token. Note! Make sure to use this method just before a request is made against the server since it might have been updated in another browser tab or window.
- Source:
Returns:
The name of the request header to put the token in.- Type
- String
-
getDefaultHeaders() → {object}
-
Get the default headers. Currently these are:
- Content-Type: application/json
- Accept-Language: [uses browser provided languages]
- Source:
Returns:
The default headers- Type
- object
-
isCsrfFilterEnabled() → {*}
-
Use this method and check if the CSRF filter is enabled before trying to set the CSRF header or parameter. Will be disabled if the filter contains no rules.
- Source:
Returns:
- Type
- *
-
onStopRequest(payload)
-
Handles requests to stop a previous XHR request.
Parameters:
Name Type Description payload
object An object that should contain a 'requestId' attribute - Source: