简体   繁体   English

强制http请求从前端超时

[英]Forcing an http request to timeout from frontend

I am making a single page application using angular, at times the backend services do not response or are down and browser takes very long time to timeout request. 我正在使用angular创建单个页面应用程序,有时后端服务没有响应或已关闭,并且浏览器需要很长的超时请求。

How can I forcefully timeout an http request from frontend in lesser time, this will help me show message to user that backend is not responding. 如何在较短的时间内强制超时来自前端的http请求,这将帮助我向用户显示后端未响应的消息。

$http config has a timeout property that you can set when making a request with $http . $http config具有timeout属性,您可以在使用$http进行请求时设置该属性。

If you want to get something done at global level for all $http can look at this SO post How to set a global http timeout in AngularJs 如果您想在所有$http全局级别上完成某件事,可以查看此SO帖子如何在AngularJs中设置全局http超时

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM