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 { eventEmitter, apiClientEmitter } = emitters;
|
||||
|
||||
const { urlWithParams, fetchOptions } = this.buildRequest({
|
||||
...options,
|
||||
url,
|
||||
securityOptions
|
||||
});
|
||||
const { urlWithParams, fetchOptions } = this.buildRequest({ ...options, url }, securityOptions);
|
||||
|
||||
const controller = new AbortController();
|
||||
fetchOptions.signal = controller.signal;
|
||||
@@ -100,19 +96,10 @@ export class SuperagentHttpClient implements HttpClient {
|
||||
return promise;
|
||||
}
|
||||
|
||||
private buildRequest({
|
||||
httpMethod,
|
||||
url,
|
||||
queryParams,
|
||||
headerParams,
|
||||
formParams,
|
||||
bodyParam,
|
||||
contentType,
|
||||
accept,
|
||||
responseType,
|
||||
returnType,
|
||||
securityOptions
|
||||
}: RequestOptions & { securityOptions: SecurityOptions }) {
|
||||
private buildRequest(
|
||||
{ httpMethod, url, queryParams, headerParams, formParams, bodyParam, contentType, accept, responseType, returnType }: RequestOptions,
|
||||
securityOptions: SecurityOptions
|
||||
) {
|
||||
const urlWithParams = new URL(url);
|
||||
urlWithParams.search = new URLSearchParams(SuperagentHttpClient.normalizeParams(queryParams)).toString();
|
||||
|
||||
|
@@ -99,15 +99,17 @@ describe('SuperagentHttpClient', () => {
|
||||
const httpMethod = 'GET';
|
||||
const securityOptions = { ...defaultSecurityOptions };
|
||||
|
||||
const request = client['buildRequest']({
|
||||
...options,
|
||||
path: '',
|
||||
httpMethod,
|
||||
url,
|
||||
bodyParam: null,
|
||||
returnType: null,
|
||||
const request = client['buildRequest'](
|
||||
{
|
||||
...options,
|
||||
path: '',
|
||||
httpMethod,
|
||||
url,
|
||||
bodyParam: null,
|
||||
returnType: null
|
||||
},
|
||||
securityOptions
|
||||
});
|
||||
);
|
||||
|
||||
expect(request.urlWithParams).toEqual(url);
|
||||
const { fetchOptions } = request;
|
||||
@@ -129,15 +131,17 @@ describe('SuperagentHttpClient', () => {
|
||||
|
||||
(isBrowser as jest.Mock).mockReturnValue(false);
|
||||
|
||||
const request = client['buildRequest']({
|
||||
...options,
|
||||
path: '',
|
||||
httpMethod,
|
||||
url,
|
||||
bodyParam: null,
|
||||
returnType: null,
|
||||
const request = client['buildRequest'](
|
||||
{
|
||||
...options,
|
||||
path: '',
|
||||
httpMethod,
|
||||
url,
|
||||
bodyParam: null,
|
||||
returnType: null
|
||||
},
|
||||
securityOptions
|
||||
});
|
||||
);
|
||||
expect(request.fetchOptions.headers['cookie']).toEqual('testCookie');
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user