I can't find any reference about how to define the type for AbortController
. I am using it in a React component like so:
const abortController = useRef();
const doRequest = () => {
abortController.current = new AbortController();
window
.fetch(url, {
method: 'GET',
signal: abortController.current.signal,
})
.then(res => res.json());
};
const cancelRequest = () => {
abortController.current.abort();
};
should work