mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
AAE-30882 Change buildRequest parameters
This commit is contained in:
@@ -48,11 +48,7 @@ export class SuperagentHttpClient implements HttpClient {
|
|||||||
const { returnType } = options;
|
const { returnType } = options;
|
||||||
const { eventEmitter, apiClientEmitter } = emitters;
|
const { eventEmitter, apiClientEmitter } = emitters;
|
||||||
|
|
||||||
const { urlWithParams, fetchOptions } = this.buildRequest({
|
const { urlWithParams, fetchOptions } = this.buildRequest({ ...options, url }, securityOptions);
|
||||||
...options,
|
|
||||||
url,
|
|
||||||
securityOptions
|
|
||||||
});
|
|
||||||
|
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
fetchOptions.signal = controller.signal;
|
fetchOptions.signal = controller.signal;
|
||||||
@@ -100,19 +96,10 @@ export class SuperagentHttpClient implements HttpClient {
|
|||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildRequest({
|
private buildRequest(
|
||||||
httpMethod,
|
{ httpMethod, url, queryParams, headerParams, formParams, bodyParam, contentType, accept, responseType, returnType }: RequestOptions,
|
||||||
url,
|
securityOptions: SecurityOptions
|
||||||
queryParams,
|
) {
|
||||||
headerParams,
|
|
||||||
formParams,
|
|
||||||
bodyParam,
|
|
||||||
contentType,
|
|
||||||
accept,
|
|
||||||
responseType,
|
|
||||||
returnType,
|
|
||||||
securityOptions
|
|
||||||
}: RequestOptions & { securityOptions: SecurityOptions }) {
|
|
||||||
const urlWithParams = new URL(url);
|
const urlWithParams = new URL(url);
|
||||||
urlWithParams.search = new URLSearchParams(SuperagentHttpClient.normalizeParams(queryParams)).toString();
|
urlWithParams.search = new URLSearchParams(SuperagentHttpClient.normalizeParams(queryParams)).toString();
|
||||||
|
|
||||||
|
@@ -99,15 +99,17 @@ describe('SuperagentHttpClient', () => {
|
|||||||
const httpMethod = 'GET';
|
const httpMethod = 'GET';
|
||||||
const securityOptions = { ...defaultSecurityOptions };
|
const securityOptions = { ...defaultSecurityOptions };
|
||||||
|
|
||||||
const request = client['buildRequest']({
|
const request = client['buildRequest'](
|
||||||
...options,
|
{
|
||||||
path: '',
|
...options,
|
||||||
httpMethod,
|
path: '',
|
||||||
url,
|
httpMethod,
|
||||||
bodyParam: null,
|
url,
|
||||||
returnType: null,
|
bodyParam: null,
|
||||||
|
returnType: null
|
||||||
|
},
|
||||||
securityOptions
|
securityOptions
|
||||||
});
|
);
|
||||||
|
|
||||||
expect(request.urlWithParams).toEqual(url);
|
expect(request.urlWithParams).toEqual(url);
|
||||||
const { fetchOptions } = request;
|
const { fetchOptions } = request;
|
||||||
@@ -129,15 +131,17 @@ describe('SuperagentHttpClient', () => {
|
|||||||
|
|
||||||
(isBrowser as jest.Mock).mockReturnValue(false);
|
(isBrowser as jest.Mock).mockReturnValue(false);
|
||||||
|
|
||||||
const request = client['buildRequest']({
|
const request = client['buildRequest'](
|
||||||
...options,
|
{
|
||||||
path: '',
|
...options,
|
||||||
httpMethod,
|
path: '',
|
||||||
url,
|
httpMethod,
|
||||||
bodyParam: null,
|
url,
|
||||||
returnType: null,
|
bodyParam: null,
|
||||||
|
returnType: null
|
||||||
|
},
|
||||||
securityOptions
|
securityOptions
|
||||||
});
|
);
|
||||||
expect(request.fetchOptions.headers['cookie']).toEqual('testCookie');
|
expect(request.fetchOptions.headers['cookie']).toEqual('testCookie');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user