javascript - 避免长 Angular $http 查询超时

标签 javascript angularjs http

我遇到了 AngularJs 应用程序的问题。我的应用程序需要向某个 python bottle 服务器发送 GET 查询,该服务器将处理脚本 3-4 分钟。

我实际上是在 angular 中使用 $http.get 方法,但一分钟后,如果我的 python 应用程序还没有回答,我会超时。 python 应用程序继续处理,但由于超时,我将无法读取我的 promise 函数中的响应。

有什么方法可以处理这种查询,同时避免浏览器和 Angular 应用程序超时?

最佳答案

您可以在 http.get() 方法的第二个参数中为您的 http 请求设置自定义超时:

$http.get('request-path', {timeout: 300000});

这会将超时设置为 300 秒 = 5 分钟。

关于javascript - 避免长 Angular $http 查询超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39932143/

相关文章:

http - 为什么 Wildfly 不监听 http 端口?

javascript - 使用外部 JS 文件将 JS 与 HTML 分离

javascript - 奇怪的 Svelte 错误 - 缺少 service-worker.js - 错误 404

javascript - Angular Filter 不适用于 ng-options

html - 如何在输入的开头设置空格?

android - QT 和 Android 8.0 : Error creating SSL context () 问题

javascript - 通过 JavaScript 自动登录到 Alfresco

javascript - 在打开的选择选项的底部动态附加一个 div

angularjs - 如何让我的 ngResource 接受自定义 header ?

java - Jakarta commons HTTPClient 无法使用 php 在我的 apache 服务器上发送发布请求