Get the meta data that was set on the request.
The meta data of the object.
Gets the URL of the request.
the URL of the request
Sets the request's Accept header to 'application/json'
Clears the config builders array and returns the instance. Useful in cases where you want to create a new request that doesn't inherit from API/factory settings that might have headers or other unwanted configuration
the updated request
Retrieves a read-only copy of configuration.
The frozen configuration object.
When called, the request will not try to parse the response
Sets the accepted MIME types for the request.
Rest
...mimeTypes: any[]An array of MIME types to accept.
Short-hand for setting the accepted MIME types to ['/'] which means the API accepts any MIME type.
Sets the credentials policy for the HTTP request.
The configuration for the credentials.
Rest
...interceptors: ErrorInterceptor[]Set the request body to a FormData object and allows customizing the form data before sending the request.
the callback function that customizes the FormData object
header name
the value for the header, omit this parameter to remove the header
name-value pairs to set as headers If value is undefined, the corresponding header will be removed if present
Set the request body as a JSON object or string.
The JSON object or string to set as the request body.
Sets an ILogger compatible logger for the request. Normally the logger will be set by the factory.
The logger to be set.
the log level to apply for this request. One of LOG_LEVEL_ERROR, LOG_LEVEL_WARN, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG defined in constants.js Overrides the default log level.
Configures the request with metadata that can be inspected later.
The key or object containing the key-value pairs to update the meta property.
Optional
param2: anyThe value to associate with the key when param1 is a string.
Sets the CORS mode to 'no-cors' and returns the current object.
Adds a query parameter to the request.
The name of the query parameter.
The value of the query parameter.
Adds multiple query parameters to the existing query parameters of the API configuration.
The query parameters to be added.
Adds a request interceptor to the request configuration. Interceptors are executed in the order they are added.
undefined
, the request will continue to the next interceptor, if present, or to the regular request handlingRest
...interceptors: RequestInterceptor[]Sets the response body transformer for the request. The provided function will be called after the request body is parsed. This is especially useful when used in conjuncion with APIs definition to hide some data massaging logic specific to the api.
Rest
...transformers: ResponseBodyTransformer[]factory.withAPIConfig({
name : 'some-api',
responseBodyTransformer : (body, request) => {
//the response.details is a JSON string that we want
//to parse before the app receives the response
body.details = JSON.parse(body.details)
return body;
}),
endpoints : {
'get-stuff' : {
endpoint : '/get-stuff'
}
}
};
const response = factory
.createAPIRequest('some-api', 'get-stuff')
.execute();
console.log(response.details.some.deep.data);
Rest
...interceptors: ResponseInterceptor[]milliseconds to wait before failing the request as timed out
Sets the uriEncodedBody
property of the config object to true
.
This function is used to indicate that the body of the request should be URL encoded.
Adds a URL parameter to the request configuration.
The name of the URL parameter.
The value of the URL parameter.
Assigns multiple query params to the request configuration.
The URL parameters to assign.
HTTP Request. This class shouldn't be instanciated directly. Use HTTPRequestFactory createXXXRequest() instead