gpt4 book ai didi

javascript - Angular 超时不起作用

转载 作者:行者123 更新时间:2023-12-03 10:06:54 25 4
gpt4 key购买 nike

我已经使用 angualrjs 以不同的方式尝试了下面的代码。但是请求 header 和应用程序流程中没有反射(reflect)连接超时。我已经浏览了许多 Angualrjs 站点。但没有输出。

   angular.module('MyApp', [])
.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.timeout = 5000;
}]);

最佳答案

看起来您正在写入错误的对象(defaults 而不是 defaults.headers)。

The defaults can also be set at runtime via the $http.defaults object in the same fashion. For example:

module.run(function($http) {  
$http.defaults.headers.common.Authorization = 'Basic YmVlcDpib29w' });
}

来自 here 。尝试这样做。

或者当您的请求发送时(与下面几行之前的来源相同):

var req = {
method: 'POST',
url: 'http://example.com',
headers: {
'Content-Type': undefined
},
data: { test: 'test' }
}

$http(req).success(function(){...}).error(function(){...});

关于javascript - Angular 超时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30319573/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com