如何中止获取请求? [英] How to abort a fetch request?
问题描述
我一直在使用新的获取API 而不是旧的 XMLHttpRequest
I've been using the new fetch API instead of the old XMLHttpRequest
太好了,但我缺少一个关键功能, xhr .abort().
It is great but I am missing one crucial function, xhr.abort().
我无法找到有关该功能的任何信息.
I can't find any information about that functionality for fetch.
谢谢.
更新: 用于中止获取的hacky解决方法 https://github.com/Morantron/poor-mans-cancelable-提取
UPDATE: hacky workaround for aborting fetch https://github.com/Morantron/poor-mans-cancelable-fetch
基本上,您是在网络工作者中启动抓取操作,然后取消该网络工作者以中止抓取操作
Basically you start the fetch in a web worker and cancel the web worker to abort the fetch
推荐答案
它仍然是一个未解决的问题 所有相关讨论都可以在这里找到
Its still an open issue All relevant discussion can be found here
https://github.com/whatwg/fetch/issues/447 :(
这篇关于如何中止获取请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!