英文:
Angular HttpClient analogue for fetch keepalive flag
问题
我正在开发一个Angular应用程序,使用它的HttpClient
。我发现fetch()
Api支持有用的keepalive
选项,以保持连接在HTML页面的生存时间之外。
fetch(someUrl, {
method: 'POST',
body: data,
keepalive: true,
});
当使用HttpClient时,我似乎找不到类似的东西。这个选项是否存在?
英文:
I am developing an Angular application using its HttpClient
. I found that fetch()
Api does support the useful keepalive
option to maintain the connection beyond the livetime of the html page.
fetch(someUrl, {
method: 'POST',
body: data,
keepalive: true,
});
I cant seem to find anything similar when using HttpClient. Does this option exist at all?
答案1
得分: 1
默认情况下,HttpModule
不依赖于 fetch
API,而是依赖于 XHR。
所以,答案是否定的。
自从16.1版本以后,你可以使用 withFetch()
切换到基于 fetch
API 的实现,但它也不支持 keepAlive
选项。
不过,你可以提出一个功能请求。
英文:
By default the HttpModule
does not rely on the fetch
API but the XHR.
So no, there is no such option.
Since 16.1, you can use withFetch()
to switch to the fetch
API base implementation but it doesn't support the keepAlive
option either.
You could open a feature request though.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论