The
abort()
method of the AbortController interface aborts a DOM request (e.g. a Fetch request)
References -
- AbortController interface
- abortcontroller npm
- abortcontroller-polyfill
- Example of the AbortController implementation
- Create an AbortController instance.
- That instance has a signal property.
- Pass the signal as a fetch option for signal.
- Call the AbortController's abort property to cancel all fetches that use that signal.
Setting the AbortController.signal as a fetch option while creating the MSGraph SDK Client instance:
import{Client,FetchOptions}from"@microsoft/microsoft-graph-client";import{AbortController}from"abort-controller";// <- import when using the abort-controller npm package.constcontroller=newAbortController();consttimeout=setTimeout(()=>{controller.abort();},150);constfetchOptions: FetchOptions={signal: controller.signal;}constclient=Client.initWithMiddleware({fetchOptions,// Pass the FetchOptions value where the AbortController.signal is set authProvider, ... });