Closed sahibalejandro closed 10 months ago
Hi @sahibalejandro,
That is likely because you can't pass axios
cancel token directly - we have an abstraction over it because some people might be using custom HttpService
and skipaxios
all together.
If you are not using custom HttpService, have you tried generating token like this?
import { createCancelToken } from '@kontent-ai/core-sdk';
const token = createCancelToken();
Brief bug description
Passing a cancel token using
.queryConfig({ cancelToken: <token> })
seems to be not working, the request is not canceled when calling thecancel()
method for the<token>
's source.What went wrong? Request is not canceled when it should be.
Repro steps
Create a cancel token source using Axios
source = axios.CancelToken.source();
Assign the token to a client request
client.item<SomeKontentItem>('some_item').queryConfig({ cancelToken: source.token }).toPromise()
Call the
cancel()
methodsource.cancel()
Expected behavior
The HTTP request should be canceled at the time
cancel()
function is calledTest environment
Additional context
Doing the exact same steps but using
axios.get(..., { cancelToken: source.token })
instead of delivery client works as expected.