@sap-cloud-sdk/http-client
Version:
SAP Cloud SDK for JavaScript http-client
31 lines • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isOriginOptions = isOriginOptions;
exports.isHttpRequestConfigWithOrigin = isHttpRequestConfigWithOrigin;
/**
* Type guard to check whether an object is of type `OriginOptions`.
* Warn: there can be an edge case that one can define a normal header like the example:
* {
* custom: {
* key: 'value'
* }
* }
* However, this will be treated as `OriginOptions`, as it contains `custom` as a key and an object as the value of the key.
* This known issue can be handled by switching from `executeHttpClient` to `executeHttpClientWithOrigin`.
* @param obj - Object to check.
* @returns `true` if the object is a `OriginOptions` object, `false` otherwise.
* @internal
*/
function isOriginOptions(obj) {
return (!!obj &&
(typeof obj['requestConfig'] === 'object' ||
typeof obj['custom'] === 'object'));
}
/**
* @internal
*/
function isHttpRequestConfigWithOrigin(requestConfig) {
return (isOriginOptions(requestConfig.headers) ||
isOriginOptions(requestConfig.params));
}
//# sourceMappingURL=http-client-types.js.map