-
Notifications
You must be signed in to change notification settings - Fork 231
Is there a way to implement a "cancel token" feature? #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yes, this would be helpful for us to support in the client. Thank you for bringing this up. |
@plamber. It is possible can a request currently when using the MS Graph JS SDK. References to cancel a fetch request - Example - const AbortController = require('abort-controller');
const controller = new AbortController();
const timeout = setTimeout(() => {
controller.abort();
}, 140);
const fetchOptions = {
signal: controller.signal // set the fetchOptions Signal
}
const client = Client.initWithMiddleware({
debugLogging: true,
authProvider,
fetchOptions // Set the fetch options here.
}); |
@nikithaqprevent won't this only work if you use 1 client per request. I would have assumed the timeout would need to wrap around an abort controller for each request, and each request would need to have it's own fetch options so that it resets the timer per request. |
You can also use the Is that what you are looking for? |
Yes, thank you @nikithauc it would be great if the example also reflected that use case. |
In some scenarios you might have the necessity to implement a cancel token pattern to avoid executing HTTP calls if they are no more valid.
An example for such a scenario might be a people picker that executes HTTP call requests but stops once the state for the typed in values has changed.
You can find here an example how such a cancel token might work in react and Axios: https://stackoverflow.com/questions/42896831/cancel-axios-get-request-when-typing-reactjs
Is there a way to have a similar pattern implemented with the Graph SDK?
AB#5998
The text was updated successfully, but these errors were encountered: