Skip to content

Commit

Permalink
add interceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
amper-fb committed Jan 9, 2024
1 parent c1bae00 commit 4da0dff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export class ApiClient {
},
});

if (options?.customAxiosOptions?.interceptors?.request) {
this.axiosInstance.interceptors.request.use(options.customAxiosOptions.interceptors.request.onFulfilled, options.customAxiosOptions.interceptors.request.onRejected);

Check failure on line 25 in src/api-client.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Argument of type '(value: AxiosRequestConfig<any>) => AxiosRequestConfig<any> | Promise<AxiosRequestConfig<any>>' is not assignable to parameter of type '(value: InternalAxiosRequestConfig<any>) => InternalAxiosRequestConfig<any> | Promise<InternalAxiosRequestConfig<any>>'.

Check failure on line 25 in src/api-client.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Argument of type '(value: AxiosRequestConfig<any>) => AxiosRequestConfig<any> | Promise<AxiosRequestConfig<any>>' is not assignable to parameter of type '(value: InternalAxiosRequestConfig<any>) => InternalAxiosRequestConfig<any> | Promise<InternalAxiosRequestConfig<any>>'.

Check failure on line 25 in src/api-client.ts

View workflow job for this annotation

GitHub Actions / build (19.x)

Argument of type '(value: AxiosRequestConfig<any>) => AxiosRequestConfig<any> | Promise<AxiosRequestConfig<any>>' is not assignable to parameter of type '(value: InternalAxiosRequestConfig<any>) => InternalAxiosRequestConfig<any> | Promise<InternalAxiosRequestConfig<any>>'.

Check failure on line 25 in src/api-client.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Argument of type '(value: AxiosRequestConfig<any>) => AxiosRequestConfig<any> | Promise<AxiosRequestConfig<any>>' is not assignable to parameter of type '(value: InternalAxiosRequestConfig<any>) => InternalAxiosRequestConfig<any> | Promise<InternalAxiosRequestConfig<any>>'.
}
if (options?.customAxiosOptions?.interceptors?.response) {
this.axiosInstance.interceptors.response.use(options.customAxiosOptions.interceptors.response.onFulfilled, options.customAxiosOptions.interceptors.response.onRejected);
}
Expand Down
8 changes: 6 additions & 2 deletions src/fireblocks-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ import {
ScreeningConfigurationsResponse,
ScreeningPolicyRuleResponse, ScreeningProviderConfigurationResponse, AuditLogsResponse,
} from "./types";
import { AxiosProxyConfig, AxiosResponse } from "axios";
import { AxiosProxyConfig, AxiosRequestConfig, AxiosResponse } from "axios";
import { PIIEncryption } from "./pii-client";
import { NcwApiClient } from "./ncw-api-client";
import { NcwSdk } from "./ncw-sdk";
Expand Down Expand Up @@ -156,13 +156,17 @@ export interface SDKOptions {
userAgent?: string;

/** Replace default https agent */
httpsAgent?: any
httpsAgent?: any;

/**
* Providing custom axios options including a response interceptor (https://axios-http.com/docs/interceptors)
*/
customAxiosOptions?: {
interceptors?: {
request?: {
onFulfilled: (value: AxiosRequestConfig<any>) => AxiosRequestConfig<any> | Promise<AxiosRequestConfig<any>>;
onRejected: (error: any) => any;
};
response?: {
onFulfilled: (value: AxiosResponse<any, any>) => AxiosResponse<any, any> | Promise<AxiosResponse<any, any>>;
onRejected: (error: any) => any;
Expand Down

0 comments on commit 4da0dff

Please sign in to comment.