File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -144,3 +144,40 @@ export class MyLoggingHandler implements Middleware {
144144}
145145```
146146Refer [ MiddlewareOptions] ( ../src/middleware/options/IMiddlewareOptions.ts ) interface to know its structure.
147+
148+ ### Modifying the Current Middleware Chain
149+
150+ ``` js
151+ // initialising client
152+ const client = MicrosoftGraph .Client .init ({
153+ defaultVersion: " v1.0" ,
154+ debugLogging: true ,
155+ authProvider : (done ) => {
156+ done (null , secrets .accessToken );
157+ },
158+ });
159+
160+ // getting the current middleware chain (in this case, it's the default one)
161+ let arr = client .getMiddlewareChain ();
162+
163+ // Initialising the Middleware chain that we created
164+ const dummyRandomHandler = new dummyRandomHandler ();
165+
166+ // adding the dummy handler in the array of middlewares at 3rd position
167+ arr .splice (2 , 0 , dummyRandomHandler);
168+
169+ // setting the new middleware chain
170+ client .setMiddlewareChain (arr);
171+
172+ // calling the api
173+ client
174+ .api (" /me" )
175+ .select (" displayName" )
176+ .get ()
177+ .then ((res ) => {
178+ console .log (res);
179+ })
180+ .catch ((err ) => {
181+ console .log (err);
182+ });
183+ ```
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ Steps for getting the raw response [i.e [Response Object](https://developer.mozi
44
55## Initialize the Client
66
7- Refer [ this documentation] ( .. /CreatingClientInstance.md ) for initializing the client.
7+ Refer [ this documentation] ( ./CreatingClientInstance.md ) for initializing the client.
88
99## Getting Raw Response by setting ResponseType
1010
You can’t perform that action at this time.
0 commit comments