You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/packages/web-api.md
+59Lines changed: 59 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -662,6 +662,65 @@ const web = new WebClient(token, { agent: proxy });
662
662
663
663
---
664
664
665
+
### Modify outgoing requests with a request interceptor
666
+
667
+
The client allows you to customize a request
668
+
[`interceptor`](https://axios-http.com/docs/interceptors) to modify outgoing requests.
669
+
Using this option allows you to modify outgoing requests to conform to the requirements of a proxy, which is a common requirement in many corporate settings.
670
+
671
+
For example you may want to wrap the original request information within a POST request:
### Using a pre-configured http client to handle outgoing requests
700
+
701
+
The client allows you to specify an
702
+
[`adapter`](https://github.com/axios/axios/blob/v1.x/README.md?plain=1#L586) to handle outgoing requests.
703
+
Using this option allows you to use a pre-configured http client, which is a common requirement in many corporate settings.
704
+
705
+
For example you may want to use an HTTP client which is already configured with logging capabilities, desired timeouts, etc.
* Custom function to modify outgoing requests. See {@link https://axios-http.com/docs/interceptors Axios interceptor documentation} for more details.
100
+
* @type {Function | undefined}
101
+
* @default undefined
102
+
*/
103
+
requestInterceptor?: RequestInterceptor;
104
+
/**
105
+
* Custom functions for modifing and handling outgoing requests.
106
+
* Useful if you would like to manage outgoing request with a custom http client.
107
+
* See {@link https://github.com/axios/axios/blob/v1.x/README.md?plain=1#L586 Axios adapter documentation} for more information.
@@ -130,6 +149,24 @@ export type PageAccumulator<R extends PageReducer> = R extends (
130
149
? A
131
150
: never;
132
151
152
+
/**
153
+
* An alias to {@link https://github.com/axios/axios/blob/v1.x/index.d.ts#L367 Axios' `InternalAxiosRequestConfig`} object,
154
+
* which is the main parameter type provided to Axios interceptors and adapters.
* An alias to {@link https://github.com/axios/axios/blob/v1.x/index.d.ts#L489 Axios' `AxiosInterceptorManager<InternalAxiosRequestConfig>` onFufilled} method,
160
+
* which controls the custom request interceptor logic
* An alias to {@link https://github.com/axios/axios/blob/v1.x/index.d.ts#L112 Axios' `AxiosAdapter`} interface,
166
+
* which is the contract required to specify an adapter
167
+
*/
168
+
exporttypeAdapterConfig=AxiosAdapter;
169
+
133
170
/**
134
171
* A client for Slack's Web API
135
172
*
@@ -196,6 +233,9 @@ export class WebClient extends Methods {
196
233
197
234
/**
198
235
* @param token - An API token to authenticate/authorize with Slack (usually start with `xoxp`, `xoxb`)
* @param {Function} [webClientOptions.requestInterceptor] - An interceptor to mutate outgoing requests. See {@link https://axios-http.com/docs/interceptors Axios interceptors}
238
+
* @param {Function} [webClientOptions.adapter] - An adapter to allow custom handling of requests. Useful if you would like to use a pre-configured http client. See {@link https://github.com/axios/axios/blob/v1.x/README.md?plain=1#L586 Axios adapter}
199
239
*/
200
240
publicconstructor(
201
241
token?: string,
@@ -212,6 +252,8 @@ export class WebClient extends Methods {
212
252
headers ={},
213
253
teamId =undefined,
214
254
attachOriginalToWebAPIRequestError =true,
255
+
requestInterceptor =undefined,
256
+
adapter =undefined,
215
257
}: WebClientOptions={},
216
258
){
217
259
super();
@@ -240,12 +282,12 @@ export class WebClient extends Methods {
0 commit comments