Skip to content

Commit 9e82379

Browse files
authored
Added custom response handler to NoAuthRestClient (#29)
Added custom response handler to NoAuthRestClient Bump dependencies
1 parent ced324f commit 9e82379

File tree

5 files changed

+167
-475
lines changed

5 files changed

+167
-475
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.5 (October 29, 2020)
2+
* Allow the response handler to be overridden at a per request level.
3+
* Bump dependencies.
4+
15
## 1.1.4 (October 20, 2020)
26
* Annual audit of the component code to check if it exposes a sensitive data in the logs
37

lib/authentication/NoAuthRestClient.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class NoAuthRestClient {
3737
// if the provided URL is an absolute path. Defaults to true
3838
async makeRequest(options) {
3939
const {
40-
url, method, body, headers = {}, urlIsSegment = true, isJson = true,
40+
url, method, body, headers = {}, urlIsSegment = true, isJson = true, responseHandler,
4141
} = options;
4242
const urlToCall = urlIsSegment
4343
? `${removeTrailingSlash(this.cfg.resourceServerUrl.trim())}/${removeLeadingSlash(url.trim())}` // Trim trailing or leading '/'
@@ -58,6 +58,10 @@ export class NoAuthRestClient {
5858

5959
const response = await this.request(requestOptions);
6060

61+
if (responseHandler) {
62+
return responseHandler(response, this.handleRestResponse.bind(this));
63+
}
64+
6165
return this.handleRestResponse(response);
6266
}
6367
}

0 commit comments

Comments
 (0)