我遇到了 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/